In my .rubocop.yml have some config for disabling some of the style cops.
Documentation:
Enabled: false
ClassAndModuleChildren:
Enabled: false
LineLength:
Max: 120
GuardClause:
Enabled: false
IfUnlessModifier:
Enabled: false
When running rubocop
in the terminal it works fine and disables the unwanted style cops and lints as usual but every time it runs i get this warning error for all the disabled cops:
Warning: no department given for Documentation.
Is there a way of disabling the warning message?
If you want to disable a cop that inspects comments, you can do so by adding an "inner comment" on the comment line. Running rubocop --autocorrect --disable-uncorrectable will create comments to disable all offenses that can't be automatically corrected.
The default configuration for RuboCop is placed in its configuration home directory ( ~/. config/rubocop/default. yml ), and all other config files inherit from it.
A qualified cop name is Department/CopName
. For example, Style/Documentation
is qualified and Documentation
is unqualified.
The documentation indicates that:
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.
But they show a warning for unqualified names. That happens 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
is only false
when the --auto-correct
option is in use. There isn't a way to disable it currently.
The only way to silence the warning is to include the department for each cop in your config like:
Style/Documentation:
Enabled: false
Style/ClassAndModuleChildren:
Enabled: false
Metrics/LineLength:
Max: 120
Style/GuardClause:
Enabled: false
Style/IfUnlessModifier:
Enabled: false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With