https://github.com/koic/rubocop-faker
A RuboCop extension for Faker.
https://github.com/koic/rubocop-faker
converter faker linter rubocop ruby static-code-analysis
Last synced: 7 months ago
JSON representation
A RuboCop extension for Faker.
- Host: GitHub
- URL: https://github.com/koic/rubocop-faker
- Owner: koic
- License: mit
- Created: 2019-09-02T07:37:58.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-02-18T08:47:52.000Z (8 months ago)
- Last Synced: 2025-03-29T03:10:25.011Z (7 months ago)
- Topics: converter, faker, linter, rubocop, ruby, static-code-analysis
- Language: Ruby
- Homepage:
- Size: 57.6 KB
- Stars: 22
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
Awesome Lists containing this project
README
# RuboCop Faker
[](https://badge.fury.io/rb/rubocop-faker)
[](https://circleci.com/gh/koic/rubocop-faker)
A [RuboCop](https://github.com/rubocop-hq/rubocop) extension for [Faker](https://github.com/faker-ruby/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](https://github.com/koic/rubocop-faker/blob/master/config/default.yml) for almost all of the Faker 2 changes.
## Installation
Just install the `rubocop-faker` gem
```sh
gem install rubocop-faker
```
or if you use bundler put this in your `Gemfile`
```ruby
gem 'rubocop-faker'
```
## Examples
Here's an example.
```ruby
Faker::Avatar.image(slug, size, format, set, bgset)
```
RuboCop Faker would convert it to the following Faker 2 form:
```ruby
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.
```console
% rubocop --plugin rubocop-faker --only Faker/DeprecatedArguments
```
Auto-correction to keyword argument style on Faker 2.
```console
% rubocop --plugin rubocop-faker --only Faker/DeprecatedArguments --autocorrect
```
### RuboCop configuration file
Add `rubocop-faker` to required extension.
```yaml
# .rubocop.yml
plugins:
- rubocop-faker
```
> [!NOTE]
> The plugin system is supported in RuboCop 1.72+. In earlier versions, use `require` instead of `plugins`.
## 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](https://opensource.org/licenses/MIT).