DEV Community

Cover image for Maintaining `.rubocop.yml`

Posted on

Maintaining `.rubocop.yml`

For a while now, every time I update rubocop gem to the latest version in my projects and then run bundle exec rubocop I would get a message that looks like this

The following cops were added to RuboCop, but are not configured. Please set Enabled to either `true` or `false` in your `.rubocop.yml` file.

Please also note that can also opt-in to new cops by default by adding this to your config:
    NewCops: enable

Lint/DuplicateRequire: # (new in 0.90)
  Enabled: true
Lint/EmptyFile: # (new in 0.90)
  Enabled: true
Lint/TrailingCommaInAttributeDeclaration: # (new in 0.90)
  Enabled: true
Lint/UselessMethodDefinition: # (new in 0.90)
  Enabled: true
Style/CombinableLoops: # (new in 0.90)
  Enabled: true
Style/KeywordParametersOrder: # (new in 0.90)
  Enabled: true
Style/RedundantSelfAssignment: # (new in 0.90)
  Enabled: true
Style/SoleNestedConditional: # (new in 0.89)
  Enabled: true
Rails/AfterCommitOverride: # (new in 2.8)
  Enabled: true
Rails/SquishedSQLHeredocs: # (new in 2.8)
  Enabled: true
Rails/WhereNot: # (new in 2.8)
  Enabled: true
For more information:
Enter fullscreen mode Exit fullscreen mode

I am not the "opt-in to new cops by default"-guy and prefer to add and configure new cops manually.

I also like to have the cops in alphabetical order.
However, manually putting new cops into order would take me some time and was an annoying task, so I wrote a script that did this work for me.

Eventually I put the script into a gem named ruboclean so anyone with the same "fetish" can use it.

Today, all I do is copy-paste the new cops into .rubocop.yml and then run ruboclean... done.

Screenshot of the resulting rubocop.yml file after running ruboclean

Satisfying. 🙂

For more information, please visit

(Cover image by nrd on unsplash)

Top comments (0)