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

Incorrect debugging message when overriding parameter #9869

Closed
shunwen opened this issue Jun 11, 2021 · 0 comments
Closed

Incorrect debugging message when overriding parameter #9869

shunwen opened this issue Jun 11, 2021 · 0 comments
Assignees
Labels

Comments

@shunwen
Copy link

shunwen commented Jun 11, 2021

The debugging message of the following code is wrong. The Style/CollectionMethods config exists in rubocop_1.yml but the message says it overrides the parameter in rubocop_2.yml.

require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"

  gem "rubocop", "1.16.1"
end

File.open('rubocop_1.yml', 'w') do |f|
  f << <<~YAML
    Style/CollectionMethods:
      Enabled: true
      PreferredMethods:
        find: detect
  YAML
end

File.open('rubocop_2.yml', 'w') do |f|
  f << <<~YAML
    Style/EmptyElse:
      EnforcedStyle: empty
  YAML
end

File.open('rubocop.yml', 'w') do |f|
  f << <<~YAML
    inherit_from:
      - rubocop_1.yml
      - rubocop_2.yml
    AllCops:
      NewCops: enable
    Style/CollectionMethods:
      Enabled: false
  YAML
end

RuboCop::ConfigLoader.debug = true
RuboCop::ConfigLoader.configuration_from_file('rubocop.yml')

Expected behavior

configuration from /Users/wen/tmp/rubocop.yml
Inheriting configuration from /Users/wen/tmp/rubocop_1.yml
Default configuration from /Users/wen/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/rubocop-1.16.1/config/default.yml
Inheriting configuration from /Users/wen/tmp/rubocop_2.yml
rubocop.yml: Style/CollectionMethods:Enabled overrides the same parameter in rubocop_1.yml

Actual behavior

configuration from /Users/wen/tmp/rubocop.yml
Inheriting configuration from /Users/wen/tmp/rubocop_1.yml
Default configuration from /Users/wen/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/rubocop-1.16.1/config/default.yml
Inheriting configuration from /Users/wen/tmp/rubocop_2.yml
rubocop.yml: Style/CollectionMethods:Enabled overrides the same parameter in rubocop_2.yml

Steps to reproduce the problem

Run the example code above

RuboCop version

1.16.1

@jonas054 jonas054 added the bug label Jul 5, 2021
@jonas054 jonas054 self-assigned this Jul 5, 2021
@koic koic closed this as completed in 3e554da Jul 5, 2021
koic added a commit that referenced this issue Jul 5, 2021
[Fix #9869] Print correct file in override warning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants