DEV Community

Cover image for Maintaining `.rubocop.yml`
Mario
Mario

Posted on

2 2

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:
  AllCops:
    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: https://docs.rubocop.org/rubocop/versioning.html
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 https://github.com/lxxxvi/ruboclean/.

(Cover image by nrd on unsplash)

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

đź‘‹ Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay