Custom RuboCop yml files to modify the cops enforced by RuboCop, shared across projects.
Built on RuboCop, rubocop-rails, and rubocop-performance. mad_rubocop.gemspec pins their versions and the minimum Ruby; CHANGELOG.md records the changes in each release.
This gem ships configuration only — no Ruby code. Consumers inherit three files:
.rubocop.yml— the entry point. Loads therubocop-railsandrubocop-performanceplugins, inherits the two files below, and setsAllCopsdefaults (NewCops: disable, so cops added in a RuboCop upgrade stay off until explicitly enabled here).lib/disabled_cops.yml— cops turned off, either as permanent house style or because the codebase isn't ready for them.lib/modified_cops.yml— cops kept on but configured to a non-default style (e.g.hash_rockets,double_quotes, outdented access modifiers).
Add this line to your application's Gemfile:
gem 'mad_rubocop'And then execute:
$ bundle
Or install it yourself as:
$ gem install mad_rubocop
Add this to your project .rubocop.yml file:
inherit_gem:
mad_rubocop: .rubocop.ymlNOTE: The Exclude setting on cops that only ignore certain files or directories cannot be set by MadRubocop.
After checking out the repo, run bin/setup to install dependencies.
Run the test suite with bundle exec rake spec. The specs validate the shipped configuration against the installed RuboCop — they confirm the config loads, the rubocop-rails and rubocop-performance plugins are present, and every referenced cop still exists (catching cops that a RuboCop upgrade renames or removes).
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.
Keeping the pinned RuboCop (and its plugins) current is the main maintenance task. The workflow:
- Bump the version constraints for
rubocop,rubocop-rails, and/orrubocop-performanceinmad_rubocop.gemspec. - Run
bundle update rubocop rubocop-rails rubocop-performance. - Run
bundle exec rake spec. The suite fails if the config references a cop that the new RuboCop renamed or removed — the failure message names the offending cop. - For each failure, update the cop name in
lib/disabled_cops.yml/lib/modified_cops.yml(or drop it if the cop no longer exists). - Because
NewCopsis disabled, cops added in the upgrade are off by default. Reviewrubocop --show-cops(or the release notes) and add any you want to disable/configure. - Bump
MadRubocop::VERSIONinversion.rb, add an entry toCHANGELOG.md, and release.
Bug reports and pull requests are welcome on GitHub at https://github.com/mxenabled/mad_rubocop.
The gem is available as open source under the terms of the MIT License.