Namely Ruby Whiff is a Ruby gem that contains common Rubocop configurations to use in your Ruby projects. New tools will be added over time, the next being ruby critic.
To install Namely Ruby Whiff, simply add it to your Gemfile:
gem 'namely_ruby_whiff', git: 'https://github.com/namely/namely_ruby_whiff.git', branch: 'master', require: false
And then run bundle install
.
Next, replace your project's .rubocop.yml
file with the following, followed by any rules or configurations you want to add or override:
inherit_gem:
namely_ruby_whiff: config/rubocop-rails.yml
For non-Rails projects, use the following file path instead: config/rubocop-vanilla.yml
.
Once you've installed the gem, you can run Rubocop with the following command to make sure it's finding the configs from the gem:
bundle exec rubocop
The gem also includes rubocop-changes
a tool to apply Rubocop to only the files that have changes in your branch.
bundle exec rubocop-changes
When adding an additional file to a rule for exclusion, the excluded files from the base config also have to be added to the local config. For example:
# in the base config from this gem
Lint/RescueException:
Exclude:
- 'app/lib/koala/evaluator.rb'
# in your local project's config
## this will no longer exclude the koala file from base
Lint/RescueException:
Exclude:
- 'app/my_weird_file.rb'
## this will work as intended
Lint/RescueException:
Exclude:
- 'app/lib/koala/evaluator.rb'
- 'app/my_weird_file.rb'