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)

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay