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

[Fix #9869] Print correct file in override warning #9912

Merged
merged 1 commit into from Jul 5, 2021
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/fix_override_warning.md
@@ -0,0 +1 @@
* [#9869](https://github.com/rubocop/rubocop/issues/9869): Fix reference to file in configuration override warning. ([@jonas054][])
2 changes: 1 addition & 1 deletion lib/rubocop/config_loader_resolver.rb
Expand Up @@ -23,7 +23,7 @@ def resolve_requires(path, hash)
def resolve_inheritance(path, hash, file, debug) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
inherited_files = Array(hash['inherit_from'])
base_configs(path, inherited_files, file)
.reverse.each_with_index do |base_config, index|
.each_with_index.reverse_each do |base_config, index|
override_department_setting_for_cops(base_config, hash)
override_enabled_for_disabled_departments(base_config, hash)

Expand Down
19 changes: 13 additions & 6 deletions spec/rubocop/config_loader_spec.rb
Expand Up @@ -349,23 +349,30 @@
let(:file_path) { '.rubocop.yml' }
let(:message) do
'.rubocop.yml: Style/For:Exclude overrides the same parameter in ' \
'.rubocop_todo.yml'
'.rubocop_2.yml'
end

before do
create_file(file_path, <<~YAML)
inherit_from: .rubocop_todo.yml
inherit_from:
- .rubocop_1.yml
- .rubocop_2.yml

Style/For:
Exclude:
- spec/requests/group_invite_spec.rb
YAML

create_file('.rubocop_todo.yml', <<~YAML)
create_file('.rubocop_1.yml', <<~YAML)
Style/StringLiterals:
Exclude:
- 'spec/models/group_spec.rb'
YAML

create_file('.rubocop_2.yml', <<~YAML)
Style/For:
Exclude:
- 'spec/models/expense_spec.rb'
- 'spec/models/group_spec.rb'
YAML
end

Expand Down Expand Up @@ -796,9 +803,9 @@ class Loop < Cop
expect(configuration_from_file['Metrics/MethodLength']
.to_set.superset?(expected.to_set)).to be(true)
end.to output(Regexp.new(<<~OUTPUT)).to_stdout
.rubocop.yml: Metrics/MethodLength:Enabled overrides the same parameter in normal.yml
.rubocop.yml: Metrics/MethodLength:Enabled overrides the same parameter in special.yml
.rubocop.yml: Metrics/MethodLength:Max overrides the same parameter in special.yml
.rubocop.yml: Metrics/MethodLength:Enabled overrides the same parameter in normal.yml
.rubocop.yml: Metrics/MethodLength:Max overrides the same parameter in normal.yml
OUTPUT
end
end
Expand Down