This repository was archived by the owner on Dec 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
RuboCop
Harry Levine edited this page May 12, 2018
·
3 revisions
RuboCop is a Ruby static code analyzer. Out of the box it will enforce many of the guidelines outlined in the community Ruby Style Guide.
To run it locally with Docker, you will call make rubocop
. This will list out any offenses that need to be addressed, before a pull request can be merged to production.
By default, it will be ran as part of the make test
command.
Some of RuboCop's cops offer an auto-correct option. Here are the steps to implement that feature, for a given cop.
For this example, we'll use the Style/StringLiterals style cop.
- Confirm that the cop is present in the
.rubocop_todo.yml
file - In the
.rubocop_todo.yml
file, confirm that the cop supports--auto-correct
- Remove the entire cop from the
.rubocop_todo.yml
file. Here is a sample implementation of that. - With Docker running, run the
make rubocop_auto_correct
command - Verify the accuracy of all of the changes before committing the code to GitHub