Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and auto-fix lots of things with Rubocop #3

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Fix and auto-fix lots of things with Rubocop #3

wants to merge 12 commits into from

Conversation

veganstraightedge
Copy link
Contributor

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.

  1. It allows 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.)
  2. It allows you to go through one by one and delete/comment out one of the rule exceptions in this file, re-run 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):

class << self
  def foo
  end
end

instead of this:

def self.foo
end

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant