【发布时间】:2019-05-02 06:59:03
【问题描述】:
我想配置 rubocop,使其没有启用任何规则,然后创建一个我想要启用的规则列表。我查看了 rubocop 文档,但只找到了禁用个别规则的方法。
【问题讨论】:
我想配置 rubocop,使其没有启用任何规则,然后创建一个我想要启用的规则列表。我查看了 rubocop 文档,但只找到了禁用个别规则的方法。
【问题讨论】:
我认为,该功能是为 this issue 实现的。
所有你需要的:
# .rubocop.yml
AllCops:
DisabledByDefault: true
现在,当您运行 rubocop 时,它将返回成功结果。例如:
▶ rubocop
Inspecting 38 files
......................................
38 files inspected, no offenses detected
要启用必要的警察,你应该只为警察设置Enable: true:
# .rubocop.yml
AllCops:
DisabledByDefault: true
Metrics/MethodLength:
Enabled: true
结果:
▶ rubocop
Inspecting 38 files
.......................C...C..........
Offenses:
# your offenses description
38 files inspected, 2 offenses detected
【讨论】: