查看旧的 Rubocop 配置:
...
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
...
default settings在 Rubocop 的网站上看起来像:
...
Style/AlignParameters:
Description: >-
Align the parameters of a method call if they span more
than one line.
StyleGuide: '#no-double-indent'
Enabled: true
...
试图找出旧样式是否已过时?,已弃用?仍然有效?
我可以see SupportedStyles
提供了这两个选项。在第一个示例中指定它们只是一种重申默认行为的方式,还是选择这两个选项的语句?
换句话说,如果我们要从我的 rubocop.yml 中删除 Style/AlignParameters
部分(或部分),我应该期待默认行为还是会被跳过?
最佳答案
看起来您发布的配置是直接从旧的 RuboCop 默认配置复制的。目前,RuboCop 为所有警察使用两个内部配置文件(除了用户定义的 rubocop.yml
):
enabled.yml/disabled.yml
这些文件有每个警察的条目。他们告诉警察默认情况下是启用还是禁用,并且他们还包含描述和样式指南中相关条目的链接(如果有的话)。
默认.yml
这个文件有一个条目,用于所有具有一些配置选项的警察。它列出了可能的配置 (SupportedStyles
) 和默认配置 (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?
这些根本不应该在您的 rubocop.yml
文件中指定,因为它们由 RuboCop 在内部使用。 (发生的是选项被覆盖,但因为它们与默认值相同,所以没有任何中断。
原因很可能是有人从 RuboCop 内部配置文件中复制了所有内容。您的 rubocop.yml
唯一相关的配置选项是:
启用
强制风格
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?
如果删除它,它仍将使用默认配置启用。
关于ruby - Rubocop 配置更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40667992/