gpt4 book ai didi

rubocop - 如何在运行 rubocop 时禁用 'warning no department given for ' COP' 消息

转载 作者:行者123 更新时间:2023-12-04 18:00:30 27 4
gpt4 key购买 nike

在我的 .rubocop.yml 中有一些用于禁用某些样式警察的配置。

Documentation:
Enabled: false
ClassAndModuleChildren:
Enabled: false
LineLength:
Max: 120
GuardClause:
Enabled: false
IfUnlessModifier:
Enabled: false

运行时 rubocop在终端中它工作正常并像往常一样禁用不需要的样式警察和 Lint ,但每次运行时我都会收到所有禁用警察的警告错误:
Warning: no department given for Documentation.
有没有办法禁用警告消息?

最佳答案

合格的警察名称是 Department/CopName .例如,Style/Documentation合格且Documentation是不合格的。

documentation表明:

Qualifying cop name with its type, e.g., Style, is recommended, but not necessary as long as the cop name is unique across all types.



但是它们对不合格的名称显示警告。发生这种情况 here :

# RuboCop::Cop::Registry
def qualified_cop_name(name, path, shall_warn = true)
badge = Badge.parse(name)
if shall_warn && department_missing?(badge, name)
print_warning(name, path)
end
return name if registered?(badge)

potential_badges = qualify_badge(badge)

case potential_badges.size
when 0 then name # No namespace found. Deal with it later in caller.
when 1 then resolve_badge(badge, potential_badges.first, path)
else raise AmbiguousCopName.new(badge, path, potential_badges)
end
end
shall_warn只是 false--auto-correct选项正在使用中。目前没有办法禁用它。

使警告静音的唯一方法是在您的配置中包含每个警察的部门,例如:
Style/Documentation:
Enabled: false
Style/ClassAndModuleChildren:
Enabled: false
Metrics/LineLength:
Max: 120
Style/GuardClause:
Enabled: false
Style/IfUnlessModifier:
Enabled: false

关于rubocop - 如何在运行 rubocop 时禁用 'warning no department given for ' COP' 消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58218587/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com