Search code examples
rubyrubocop

Rubocop disable all rules and create a whilelist of enabled rules


I want to configure rubocop so it has no rules enabled and then create a list of the rules I do want enabled. I had a look a the rubocop docs but only found ways to disable individual rules.


Solution

  • If you're adding rubocop to an existing project a powerful soluion is to run

    rubocop --auto-gen-config
    

    This auto-generates a rubocop.todo.yml with all the current offending cops disabled with the most useful specificity. This way over time you can remove the disabled cops in the todo file and incrementally improve your code quality as and when appropriate.