Meltemi
Meltemi

Reputation: 38359

Rubocop config changes

Looking at an old Rubocop config:

...
Style/AlignParameters:
  Description: Align the parameters of a method call if they span more than one line.
  StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-double-indent
  Enabled: true
  EnforcedStyle: with_first_parameter
  SupportedStyles:
  - with_first_parameter
  - with_fixed_indentation
...

The default settings on Rubocop's site look like:

...
Style/AlignParameters:
  Description: >-
                 Align the parameters of a method call if they span more
                 than one line.
  StyleGuide: '#no-double-indent'
  Enabled: true
...

Trying to find out if the old style is obsolete?, deprecated? still valid?

I can see SupportedStyles has those two options available. Does specifying them in the first example just a way of restating the default behavior or is that a statement selecting both those options?

Put another way, if we were to remove the Style/AlignParameters section (or parts of it) from my rubocop.yml should I expect the default behavior or will it be skipped?

Upvotes: 2

Views: 700

Answers (1)

Drenmi
Drenmi

Reputation: 8777

It looks like the configuration you posted has been copied directly from an old RuboCop default configuration. Currently, RuboCop uses two internal configuration files (in addition to the user defined rubocop.yml) for all cops:


enabled.yml / disabled.yml

These files have an entry for every cop. They tell if the cop is enabled or disabled by default, and they also hold a description and a link to the relevant entry in the style guide (if any.)

default.yml

This file has an entry for all cops that have some configuration options. It lists the possible configurations (SupportedStyles), and the default one (EnforcedStyle).


Trying to find out if the old style is obsolete?, deprecated? still valid? I can see SupportedStyles has those two options available. Does specifying them in the first example just a way of restating the default behavior or is that a statement selecting both those options?

These shouldn't be specified in your rubocop.yml file at all, as they are used internally by RuboCop. (What happens is the options are overwritten, but because they are the same as the defaults, nothing breaks.

The reason it is there is likely that someone copied everything from the RuboCop internal configuration file. The only relevant configuration options for your rubocop.yml are:

  • Enabled
  • EnforcedStyle

Put another way, if we were to remove the Style/AlignParameters section (or parts of it) from my rubocop.yml should I expect the default behavior or will it be skipped?

If you remove it, it will still be enabled with the default configuration.

Upvotes: 1

Related Questions