在 Rubocop 输出中查找违规警察的姓名
Find name of offending cop in Rubocop output
在 运行 Rubocop 之后:
bundle exec rubocop
我得到这个输出:
Inspecting 3 files
C..
Offenses:
lib/main.rb:145:3: C: Use SCREAMING_SNAKE_CASE for constants.
InternalCache = if RUBY_ENGINE == 'ruby'
^^^^^^^^^^^^^
3 files inspected, 1 offense detected
我的问题是:如果我选择忽略此违规行为,我如何才能找到我必须禁用的规则的名称。
我要找的名字是我要在 # rubocop:disable
评论中使用的名字:
# rubocop:disable Metrics/BlockLength
谢谢!
如果你 运行 rubocop -h
你会看到有一个选项 --display-cop-names
。
(这似乎是 enabled by default 所以也许你使用的是旧版本的 RuboCop)。
在 运行 Rubocop 之后:
bundle exec rubocop
我得到这个输出:
Inspecting 3 files
C..
Offenses:
lib/main.rb:145:3: C: Use SCREAMING_SNAKE_CASE for constants.
InternalCache = if RUBY_ENGINE == 'ruby'
^^^^^^^^^^^^^
3 files inspected, 1 offense detected
我的问题是:如果我选择忽略此违规行为,我如何才能找到我必须禁用的规则的名称。
我要找的名字是我要在 # rubocop:disable
评论中使用的名字:
# rubocop:disable Metrics/BlockLength
谢谢!
如果你 运行 rubocop -h
你会看到有一个选项 --display-cop-names
。
(这似乎是 enabled by default 所以也许你使用的是旧版本的 RuboCop)。