Skip to content

Commit

Permalink
Bump RuboCop Performance to 1.11
Browse files Browse the repository at this point in the history
This PR bumps RuboCop Performance to 1.11 and prevents random build error
#9721 cause by it.

And the following tests that fail randomly are pending.

```consle
bundle exec rspec spec/rubocop/config_obsoletion_spec.rb
```
  • Loading branch information
koic authored and bbatsov committed Aug 17, 2021
1 parent 61971aa commit 4a52615
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
4 changes: 1 addition & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ gem 'bump', require: false
gem 'memory_profiler', platform: :mri
gem 'rake', '~> 13.0'
gem 'rspec', '~> 3.7'
# RuboCop Performance upgrade to 1.11 is postponed until
# https://github.com/rubocop/rubocop/pull/9721 will be resolved.
gem 'rubocop-performance', '~> 1.10.0'
gem 'rubocop-performance', '~> 1.11.0'
gem 'rubocop-rake', '~> 0.6.0'
gem 'rubocop-rspec', '~> 2.3.0'
# Workaround for cc-test-reporter with SimpleCov 0.18.
Expand Down
58 changes: 30 additions & 28 deletions spec/rubocop/config_obsoletion_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,47 +262,49 @@
OUTPUT
end

it 'prints a warning message' do
# FIXME: Workaround for the following random failure test.
# https://app.circleci.com/pipelines/github/rubocop/rubocop/5075/workflows/758481f3-39fa-4a89-9fb2-c6e78d3b4ff8/jobs/194419
xit 'prints a warning message' do
config_obsoletion.reject_obsolete!
raise 'Expected a RuboCop::ValidationError'
rescue RuboCop::ValidationError => e
expect(expected_message).to eq(e.message)
end
end
end

context 'when the extensions are loaded via inherit_gem', :restore_registry do
let(:resolver) { RuboCop::ConfigLoaderResolver.new }
let(:gem_root) { File.expand_path('gems') }
context 'when the extensions are loaded via inherit_gem', :restore_registry do
let(:resolver) { RuboCop::ConfigLoaderResolver.new }
let(:gem_root) { File.expand_path('gems') }

let(:hash) do
{
'inherit_gem' => { 'rubocop-includes' => '.rubocop.yml' },
'Performance/Casecmp' => { Enabled: true }
}
end
let(:hash) do
{
'inherit_gem' => { 'rubocop-includes' => '.rubocop.yml' },
'Performance/Casecmp' => { Enabled: true }
}
end

before do
create_file("#{gem_root}/rubocop-includes/.rubocop.yml", <<~YAML)
require:
- rubocop-performance
YAML
before do
create_file("#{gem_root}/rubocop-includes/.rubocop.yml", <<~YAML)
require:
- rubocop-performance
YAML

# Mock out a gem in order to test `inherit_gem`.
gem_class = Struct.new(:gem_dir)
mock_spec = gem_class.new(File.join(gem_root, 'rubocop-includes'))
allow(Gem::Specification).to receive(:find_by_name)
.with('rubocop-includes').and_return(mock_spec)
# Mock out a gem in order to test `inherit_gem`.
gem_class = Struct.new(:gem_dir)
mock_spec = gem_class.new(File.join(gem_root, 'rubocop-includes'))
allow(Gem::Specification).to receive(:find_by_name)
.with('rubocop-includes').and_return(mock_spec)

# Resolve `inherit_gem`
resolver.resolve_inheritance_from_gems(hash)
resolver.resolve_inheritance(loaded_path, hash, loaded_path, false)
# Resolve `inherit_gem`
resolver.resolve_inheritance_from_gems(hash)
resolver.resolve_inheritance(loaded_path, hash, loaded_path, false)

allow(configuration).to receive(:loaded_features).and_call_original
end
allow(configuration).to receive(:loaded_features).and_call_original
end

it 'does not raise a ValidationError' do
expect { config_obsoletion.reject_obsolete! }.not_to raise_error
end
it 'does not raise a ValidationError' do
expect { config_obsoletion.reject_obsolete! }.not_to raise_error
end
end

Expand Down

0 comments on commit 4a52615

Please sign in to comment.