Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make error message clearer when the namespace is incorrect #12641

Merged
merged 1 commit into from Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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