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 duplicate extension cop versions when rubocop -V #9356

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
@@ -0,0 +1 @@
* [#9356](https://github.com/rubocop-hq/rubocop/pull/9356): Fix duplicate extension cop versions when using `rubocop -V`. ([@koic][])
2 changes: 1 addition & 1 deletion lib/rubocop/config_loader.rb
Expand Up @@ -175,7 +175,7 @@ def merge_with_default(config, config_file, unset_nil: true)
end

def loaded_features
@loaded_features.flatten.compact
@loaded_features.flatten.compact.uniq
end

# @api private
Expand Down
25 changes: 25 additions & 0 deletions spec/rubocop/cli/cli_options_spec.rb
Expand Up @@ -177,6 +177,31 @@
end
end

context 'when requiring redundant extension cop' do
before do
create_file('ext.yml', <<~YAML)
require:
- rubocop-rspec
YAML
create_file('.rubocop.yml', <<~YAML)
inherit_from: ext.yml
require:
- rubocop-performance
- rubocop-rspec
YAML
end

it 'shows with version of each extension cop once' do
output = `ruby -I . "#{rubocop}" -V --disable-pending-cops`
expect(output).to include(RuboCop::Version::STRING)
expect(output).to match(/Parser \d+\.\d+\.\d+/)
expect(output).to match(/rubocop-ast \d+\.\d+\.\d+/)
expect(output).to match(
/- rubocop-performance \d+\.\d+\.\d+\n - rubocop-rspec \d+\.\d+\.\d+\n\z/
)
end
end

context 'when there are pending cops' do
let(:pending_cop_warning) { <<~PENDING_COP_WARNING }
The following cops were added to RuboCop, but are not configured. Please set Enabled to either `true` or `false` in your `.rubocop.yml` file.
Expand Down