Pending cops in Rubocop to make upgrade easier

Whenever a new version of Rubocop comes out, there are always some new cops. If our code is not compatible with new cops, then the rubocop build fails. With every new release, we have to spend time to make our code compatible with the new cops. Well not any more!

Starting Rubocop 0.79.0 onwards, new cops will be marked as pending. Rubocop will print a message listing the pending cops so that users know which cops are introduced in a release.

➜  codetriage git:(master) ✗ rubocop
The following cops were added to RuboCop, but are not configured. 
Please set Enabled to either `true` or `false` in your 
`.rubocop.yml` file:
 - Style/HashEachMethods
 - Style/HashTransformKeys
 - Style/HashTransformValues

Disabling all cops by default

Rubocop also provides a feature to disable all cops by default. This can be achieved as follows:

# .rubocop.yml

AllCops:
  DisabledByDefault: true

In this case, we need to explicitly enable selected cops that we want to use in our codebase.

# .rubocop.yml

AllCops:
  DisabledByDefault: true

Layout/ArrayAlignment:
 Enabled: true

Layout/HashAlignment:
 Enabled: true

Layout/ParameterAlignment:
 Enabled: true

When all cops are disabled as shown above, the warning about pending cops is not shown. Because in this case, we are in control of which cops we are using in our application.

What happens to pending cops?

Pending cops will be marked as enabled or disabled during a major release of Rubocop. In case of Rubocop, next major release will be 1.0. This policy is on the same lines of how ESLint introduces new linters.


You can join my mailing list to be in touch with the latest changes happening to Rubocop.