Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RuboCop: Different parameters for different directories

I'm wondering if there are a way of specifying different parameters for different directories.

For instance, I would like RuboCop to be more gentle with my tests. Is there a way to re-write this setup?

Metrics/AbcSize:
  Max: 20
  Exclude:
    - 'spec/**/*'

Metrics/AbcSize:
  Max: 30
  Include:
    - 'spec/**/*'

Right now I'm getting .rubocop.yml:X: 'Metrics/AbcSize' is concealed by line Y

Update:

Ended up with two .rubocop.yml files:

[project-root]/.rubocop.yml:

Metrics/AbcSize:
  Max: 20

[project-root]/spec/.rubocop.yml:

inherit_from: ../.rubocop.yml

Metrics/AbcSize:
  Max: 30
like image 470
Stefan Avatar asked Jan 26 '23 13:01

Stefan


1 Answers

Create separate .rubocop.yml in /spec with desired rules. Rubocop will pick it up

RuboCop will start looking for the configuration file in the directory where the inspected file is and continue its way up to the root directory.

Ref https://rubocop.readthedocs.io/en/latest/configuration/

like image 109
Martin Zinovsky Avatar answered Feb 03 '23 18:02

Martin Zinovsky