Fix and auto-fix lots of things with Rubocop #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://github.com/rubocop-hq/rubocop
rubocop -a
finds and fixes most things on its own.After that, I went through the easy / low hang fruit Rubocop warnings (aka "offenses") and fixed those up.
I added a small and reasonable
.rubocop.yml
config file which adds a few opinions to the default Rubocop ones. It also specifies that this is a Ruby 2.3 (current system Ruby) project. You'll want to change that if you ever use a different Ruby or if macOS updates their system Ruby.In addition to
.rubocop.yml
, I added.rubocop_todo.yml
. This does a couple things at once.rubocop
to pass with no warnings, so that that you can see if you create any new ones. (I know you like to treat your warnings as errors.)rubocop
, see the warnings, decide what to do for them.The ones I left behind have too much personal preference baked in for me to decide for you. Line length is a big one. Another is class method style.
This is preferred (by Rubocop, me, and lots of Rubyland):
instead of this:
Your call. Either make some changes to get
rubocop
to pass and remove the rule exceptions from.rubocop_todo.yml
OR codify those exceptions by moving them to.rubocop.yml
proper.Either way, the goal is to get rid of
.rubocop_todo.yml
which is meant as a transitional file while you make the changes.Make sense? Questions, beep me.