0.23
Low commit activity in last 3 years
A long-lived project that still receives updates
A RuboCop extension for Faker.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 2.12.0
>= 1.13.0
 Project Readme

RuboCop Faker

Gem Version CircleCI

A RuboCop extension for Faker.

RuboCop Faker is a tool for converting your Faker's methods to the latest Faker argument style with static code analysis.

With RuboCop Faker you can upgrade your Faker 1 codes to Faker 2 in no time. It supports conversions for almost all of the Faker 2 changes.

Installation

Just install the rubocop-faker gem

gem install rubocop-faker

or if you use bundler put this in your Gemfile

gem 'rubocop-faker'

Examples

Here's an example.

Faker::Avatar.image(slug, size, format, set, bgset)

RuboCop Faker would convert it to the following Faker 2 form:

Faker::Avatar.image(slug: slug, size: size, format: format, set: set, bgset: bgset)

Usage

You need to tell RuboCop to load the Faker extension.

This gem offers the only Faker/DeprecatedArguments cop. It is intended to convert a Faker 2 compatible interface.

Command line

Check positional argument style before Faker 2.

% rubocop --require rubocop-faker --only Faker/DeprecatedArguments

Auto-correction to keyword argument style on Faker 2.

% rubocop --require rubocop-faker --only Faker/DeprecatedArguments --autocorrect

RuboCop configuration file

Add rubocop-faker to required extension.

# .rubocop.yml
require:
  - rubocop-faker

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/koic/rubocop-faker.

License

The gem is available as open source under the terms of the MIT License.