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.o 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
Rubocop also provides a feature to disable all cops by default. This can be achieved as follows:
# .rubocop.yml AllCops: DisabledByDefault: false
In this case, we need to explicitly enable selected cops that we want to use in our codebase.
# .rubocop.yml AllCops: DisabledByDefault: false 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.
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.
All coders welcome
Level up every day