RuboCop:不同目录的不同参数
RuboCop: Different parameters for different directories
我想知道是否有一种方法可以为不同的目录指定不同的参数。
例如,我希望 RuboCop 对我的测试更加温和。有没有办法重写这个设置?
Metrics/AbcSize:
Max: 20
Exclude:
- 'spec/**/*'
Metrics/AbcSize:
Max: 30
Include:
- 'spec/**/*'
现在我得到 .rubocop.yml:X: 'Metrics/AbcSize' is concealed by line Y
更新:
最后得到两个 .rubocop.yml
个文件:
[project-root]/.rubocop.yml
:
Metrics/AbcSize:
Max: 20
[project-root]/spec/.rubocop.yml
:
inherit_from: ../.rubocop.yml
Metrics/AbcSize:
Max: 30
使用所需规则在 /spec
中创建单独的 .rubocop.yml
。 Rubocop 会捡起来的
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.
我想知道是否有一种方法可以为不同的目录指定不同的参数。
例如,我希望 RuboCop 对我的测试更加温和。有没有办法重写这个设置?
Metrics/AbcSize:
Max: 20
Exclude:
- 'spec/**/*'
Metrics/AbcSize:
Max: 30
Include:
- 'spec/**/*'
现在我得到 .rubocop.yml:X: 'Metrics/AbcSize' is concealed by line Y
更新:
最后得到两个 .rubocop.yml
个文件:
[project-root]/.rubocop.yml
:
Metrics/AbcSize:
Max: 20
[project-root]/spec/.rubocop.yml
:
inherit_from: ../.rubocop.yml
Metrics/AbcSize:
Max: 30
使用所需规则在 /spec
中创建单独的 .rubocop.yml
。 Rubocop 会捡起来的
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.