Skip to content

Commit

Permalink
Update error message on incorrect badge
Browse files Browse the repository at this point in the history
  • Loading branch information
maruth-stripe committed Jan 24, 2024
1 parent eef0a83 commit f063d08
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog/change_error_message_on_incorrect_namespace.md
@@ -0,0 +1 @@
* [#12641](https://github.com/rubocop/rubocop/pull/12641): Make error message clearer when the namespace is incorrect. ([@maruth-stripe][])
2 changes: 1 addition & 1 deletion lib/rubocop/cop/registry.rb
Expand Up @@ -300,7 +300,7 @@ def resolve_badge(given_badge, real_badge, source_path)
unless given_badge.match?(real_badge)
path = PathUtil.smart_path(source_path)
warn "#{path}: #{given_badge} has the wrong namespace - " \
"should be #{real_badge.department}"
"replace it with #{given_badge.with_department(real_badge.department)}"
end

real_badge.to_s
Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/cli_spec.rb
Expand Up @@ -469,7 +469,7 @@ def and_with_args
expect(cli.run(['--format', 'emacs', 'example.rb'])).to eq(1)
expect($stderr.string)
.to eq(['example.rb: Style/LineLength has the wrong ' \
'namespace - should be Layout',
'namespace - replace it with Layout/LineLength',
''].join("\n"))
# 2 real cops were disabled, and 1 that was incorrect
# 2 real cops was enabled, but only 1 had been disabled correctly
Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/config_loader_spec.rb
Expand Up @@ -854,7 +854,7 @@ def enabled?(cop)
.to output(
a_string_including(
'.rubocop.yml: Custom/Loop has the ' \
"wrong namespace - should be Lint\n"
"wrong namespace - replace it with Lint/Loop\n"
)
).to_stderr
end
Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/cop/registry_spec.rb
Expand Up @@ -114,7 +114,7 @@

it 'emits a warning when namespace is incorrect' do
warning = '/app/.rubocop.yml: Style/MethodLength has the wrong ' \
"namespace - should be Metrics\n"
"namespace - replace it with Metrics/MethodLength\n"
qualified = nil

expect do
Expand Down

0 comments on commit f063d08

Please sign in to comment.