From ee062cfd5ff4b4ddc4a2b753e617e6ad8edc2c45 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Tue, 19 Dec 2023 13:30:20 +0100 Subject: [PATCH] rubocop: Update to voxpupuli-rubocop 2.1.0 --- .rubocop_todo.yml | 59 ++++++++++++++-- beaker-puppet.gemspec | 2 +- .../install_utils/foss_utils_spec.rb | 68 +++++++++---------- 3 files changed, 87 insertions(+), 42 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3deb84e..5b52fec 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2023-05-05 13:27:13 UTC using RuboCop version 1.50.2. +# on 2023-12-19 12:29:40 UTC using RuboCop version 1.57.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -15,6 +15,7 @@ Gemspec/DeprecatedAttributeAssignment: - 'beaker-puppet.gemspec' # Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowedMethods, AllowedPatterns. Lint/AmbiguousBlockAssociation: Exclude: @@ -79,8 +80,14 @@ Lint/ParenthesesAsGroupedExpression: - 'spec/beaker-puppet/helpers/facter_helpers_spec.rb' - 'spec/beaker-puppet/helpers/puppet_helpers_spec.rb' -# Offense count: 2 +# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). +Lint/RedundantCopDisableDirective: + Exclude: + - 'spec/beaker-puppet/install_utils/foss_utils_spec.rb' + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). Lint/RedundantRequireStatement: Exclude: - 'spec/spec_helper.rb' @@ -133,6 +140,7 @@ Lint/UnusedMethodArgument: - 'spec/beaker-puppet/install_utils/windows_utils_spec.rb' # Offense count: 17 +# This cop supports unsafe autocorrection (--autocorrect-all). Lint/UselessAssignment: Exclude: - 'acceptance/tests/clone_git_repo_on_test.rb' @@ -276,12 +284,13 @@ Performance/StringReplacement: - 'lib/beaker-puppet/install_utils/windows_utils.rb' - 'spec/beaker-puppet/install_utils/windows_utils_spec.rb' -# Offense count: 5 +# Offense count: 6 # This cop supports unsafe autocorrection (--autocorrect-all). RSpec/BeEq: Exclude: - 'spec/beaker-puppet/helpers/tk_helpers_spec.rb' - 'spec/beaker-puppet/install_utils/ezbake_utils_spec.rb' + - 'spec/beaker-puppet/install_utils/foss_utils_spec.rb' - 'spec/beaker-puppet/install_utils/module_utils_spec.rb' # Offense count: 2 @@ -336,6 +345,12 @@ RSpec/EmptyLineAfterHook: - 'spec/beaker-puppet/helpers/tk_helpers_spec.rb' - 'spec/beaker-puppet/install_utils/foss_utils_spec.rb' +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +RSpec/Eq: + Exclude: + - 'spec/beaker-puppet/install_utils/foss_utils_spec.rb' + # Offense count: 138 # Configuration parameters: CountAsOne. RSpec/ExampleLength: @@ -388,7 +403,7 @@ RSpec/HookArgument: - 'spec/beaker-puppet/install_utils/windows_utils_spec.rb' # Offense count: 2 -# Configuration parameters: Max. +# Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns. RSpec/IndexedLet: Exclude: - 'spec/beaker-puppet/install_utils/foss_utils_spec.rb' @@ -494,6 +509,16 @@ RSpec/ReceiveCounts: - 'spec/beaker-puppet/helpers/puppet_helpers_spec.rb' - 'spec/beaker-puppet/install_utils/foss_utils_spec.rb' +# Offense count: 66 +# This cop supports unsafe autocorrection (--autocorrect-all). +RSpec/ReceiveMessages: + Exclude: + - 'spec/beaker-puppet/helpers/puppet_helpers_spec.rb' + - 'spec/beaker-puppet/install_utils/foss_utils_spec.rb' + - 'spec/beaker-puppet/install_utils/module_utils_spec.rb' + - 'spec/beaker-puppet/install_utils/windows_utils_spec.rb' + - 'spec/helpers.rb' + # Offense count: 19 # This cop supports safe autocorrection (--autocorrect). RSpec/ReceiveNever: @@ -519,6 +544,24 @@ RSpec/ReturnFromStub: - 'spec/beaker-puppet/install_utils/foss_utils_spec.rb' - 'spec/beaker-puppet/install_utils/puppet5_spec.rb' +# Offense count: 11 +# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. +# Include: **/*_spec.rb +RSpec/SpecFilePathFormat: + Exclude: + - '**/spec/routing/**/*' + - 'spec/beaker-puppet/helpers/facter_helpers_spec.rb' + - 'spec/beaker-puppet/helpers/host_helpers_spec.rb' + - 'spec/beaker-puppet/helpers/puppet_helpers_spec.rb' + - 'spec/beaker-puppet/helpers/tk_helpers_spec.rb' + - 'spec/beaker-puppet/install_utils/ezbake_utils_spec.rb' + - 'spec/beaker-puppet/install_utils/foss_utils_spec.rb' + - 'spec/beaker-puppet/install_utils/module_utils_spec.rb' + - 'spec/beaker-puppet/install_utils/puppet5_spec.rb' + - 'spec/beaker-puppet/install_utils/puppet_utils_spec.rb' + - 'spec/beaker-puppet/install_utils/windows_utils_spec.rb' + - 'spec/beaker-puppet/wrappers_spec.rb' + # Offense count: 106 RSpec/StubbedMock: Exclude: @@ -642,11 +685,13 @@ Style/ClassAndModuleChildren: # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. Style/CollectionCompact: Exclude: - 'lib/beaker-puppet/install_utils/foss_utils.rb' # Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). Style/CombinableLoops: Exclude: - 'spec/beaker-puppet/install_utils/windows_utils_spec.rb' @@ -694,7 +739,7 @@ Style/IdenticalConditionalBranches: - 'lib/beaker-puppet/helpers/tk_helpers.rb' - 'lib/beaker-puppet/install_utils/ezbake_utils.rb' -# Offense count: 12 +# Offense count: 13 # This cop supports safe autocorrection (--autocorrect). Style/IfUnlessModifier: Exclude: @@ -736,7 +781,7 @@ Style/NonNilCheck: Exclude: - 'lib/beaker-puppet/install_utils/foss_utils.rb' -# Offense count: 10 +# Offense count: 11 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. # SupportedStyles: predicate, comparison @@ -834,7 +879,7 @@ Style/ZeroLengthPredicate: - 'lib/beaker-puppet/helpers/puppet_helpers.rb' - 'lib/beaker-puppet/install_utils/foss_utils.rb' -# Offense count: 121 +# Offense count: 122 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. # URISchemes: http, https diff --git a/beaker-puppet.gemspec b/beaker-puppet.gemspec index 0c54115..9e3f68e 100644 --- a/beaker-puppet.gemspec +++ b/beaker-puppet.gemspec @@ -23,7 +23,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'rake', '~> 13.0' s.add_development_dependency 'rspec', '~> 3.0' s.add_development_dependency 'rspec-its', '~> 1.3' - s.add_development_dependency 'voxpupuli-rubocop', '~> 2.0' + s.add_development_dependency 'voxpupuli-rubocop', '~> 2.1.0' # Acceptance Testing Dependencies s.add_development_dependency 'beaker-vmpooler', '~> 1.4' diff --git a/spec/beaker-puppet/install_utils/foss_utils_spec.rb b/spec/beaker-puppet/install_utils/foss_utils_spec.rb index d1fb8ca..dc7bd19 100644 --- a/spec/beaker-puppet/install_utils/foss_utils_spec.rb +++ b/spec/beaker-puppet/install_utils/foss_utils_spec.rb @@ -202,9 +202,9 @@ def logger context 'lookup_in_env' do it 'returns a default properly' do env_var = subject.lookup_in_env('noway', 'nonesuch', 'returnme') - expect(env_var).to be == 'returnme' + expect(env_var).to eq 'returnme' env_var = subject.lookup_in_env('noway', nil, 'returnme') - expect(env_var).to be == 'returnme' + expect(env_var).to eq 'returnme' end it 'finds correct env variable' do allow(ENV).to receive(:[]).with(nil).and_return(nil) @@ -212,13 +212,13 @@ def logger allow(ENV).to receive(:[]).with('NONESUCH').and_return('present') allow(ENV).to receive(:[]).with('NOWAY_PROJ_NONESUCH').and_return('exists') env_var = subject.lookup_in_env('nonesuch', 'noway-proj', 'fail') - expect(env_var).to be == 'exists' + expect(env_var).to eq 'exists' env_var = subject.lookup_in_env('nonesuch') - expect(env_var).to be == 'present' + expect(env_var).to eq 'present' env_var = subject.lookup_in_env('reallynone') - expect(env_var).to be == nil # rubocop:disable Style/NilComparison + expect(env_var).to eq nil # rubocop:disable Style/NilComparison env_var = subject.lookup_in_env('reallynone', nil, 'default') - expect(env_var).to be == 'default' + expect(env_var).to eq 'default' end end @@ -229,21 +229,21 @@ def logger allow(ENV).to receive(:[]).with('PUPPET_FORK').and_return(nil) allow(ENV).to receive(:[]).with('PUPPET_SERVER').and_return(nil) url = subject.build_giturl('puppet') - expect(url).to be == 'https://github.com/puppetlabs/puppet.git' + expect(url).to eq 'https://github.com/puppetlabs/puppet.git' url = subject.build_giturl('puppet', 'er0ck') - expect(url).to be == 'https://github.com/er0ck/puppet.git' + expect(url).to eq 'https://github.com/er0ck/puppet.git' url = subject.build_giturl('puppet', 'er0ck', 'bitbucket.com') - expect(url).to be == 'https://bitbucket.com/er0ck-puppet.git' + expect(url).to eq 'https://bitbucket.com/er0ck-puppet.git' url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'https://') - expect(url).to be == 'https://github.com/er0ck/puppet.git' + expect(url).to eq 'https://github.com/er0ck/puppet.git' url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'https') - expect(url).to be == 'https://github.com/er0ck/puppet.git' + expect(url).to eq 'https://github.com/er0ck/puppet.git' url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'git@') - expect(url).to be == 'git@github.com:er0ck/puppet.git' + expect(url).to eq 'git@github.com:er0ck/puppet.git' url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'git') - expect(url).to be == 'git@github.com:er0ck/puppet.git' + expect(url).to eq 'git@github.com:er0ck/puppet.git' url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'ssh') - expect(url).to be == 'git@github.com:er0ck/puppet.git' + expect(url).to eq 'git@github.com:er0ck/puppet.git' end it 'uses ENV to build urls properly' do @@ -252,21 +252,21 @@ def logger allow(ENV).to receive(:[]).with('PUPPET_FORK').and_return('er0ck/repo') allow(ENV).to receive(:[]).with('PUPPET_SERVER').and_return('gitlab.com') url = subject.build_giturl('puppet') - expect(url).to be == 'https://gitlab.com/er0ck/repo-puppet.git' + expect(url).to eq 'https://gitlab.com/er0ck/repo-puppet.git' url = subject.build_giturl('puppet', 'er0ck') - expect(url).to be == 'https://gitlab.com/er0ck-puppet.git' + expect(url).to eq 'https://gitlab.com/er0ck-puppet.git' url = subject.build_giturl('puppet', 'er0ck', 'bitbucket.com') - expect(url).to be == 'https://bitbucket.com/er0ck-puppet.git' + expect(url).to eq 'https://bitbucket.com/er0ck-puppet.git' url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'https://') - expect(url).to be == 'https://github.com/er0ck/puppet.git' + expect(url).to eq 'https://github.com/er0ck/puppet.git' url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'https') - expect(url).to be == 'https://github.com/er0ck/puppet.git' + expect(url).to eq 'https://github.com/er0ck/puppet.git' url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'git@') - expect(url).to be == 'git@github.com:er0ck/puppet.git' + expect(url).to eq 'git@github.com:er0ck/puppet.git' url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'git') - expect(url).to be == 'git@github.com:er0ck/puppet.git' + expect(url).to eq 'git@github.com:er0ck/puppet.git' url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'ssh') - expect(url).to be == 'git@github.com:er0ck/puppet.git' + expect(url).to eq 'git@github.com:er0ck/puppet.git' end end @@ -278,9 +278,9 @@ def logger it "handles #{type[:protocol]} uris" do uri = "#{type[:path]}#master" repo_info = subject.extract_repo_info_from uri - expect(repo_info[:name]).to be == 'project' - expect(repo_info[:path]).to be == type[:path] - expect(repo_info[:rev]).to be == 'master' + expect(repo_info[:name]).to eq 'project' + expect(repo_info[:path]).to eq type[:path] + expect(repo_info[:rev]).to eq 'master' end end end @@ -291,9 +291,9 @@ def logger { name: 'puppet_plugin' }, { name: 'puppet' }, { name: 'facter' }, ] ordered_repos = subject.order_packages named_repos - expect(ordered_repos[0][:name]).to be == 'facter' - expect(ordered_repos[1][:name]).to be == 'puppet' - expect(ordered_repos[2][:name]).to be == 'puppet_plugin' + expect(ordered_repos[0][:name]).to eq 'facter' + expect(ordered_repos[1][:name]).to eq 'puppet' + expect(ordered_repos[2][:name]).to eq 'puppet_plugin' end end @@ -313,7 +313,7 @@ def logger subject.instance_variable_set(:@metadata, {}) version = subject.find_git_repo_versions(host, path, repository) - expect(version).to be == { 'name' => '2' } + expect(version).to be == { 'name' => '2' } # rubocop:ignore RSpec/Eq end end @@ -1005,7 +1005,7 @@ def stub_uninteresting_portions_of_install_puppetlabs_dev_repo! expect(subject).to receive(:install_a_puppet_msi_on).with(host, opts) subject.install_puppet_agent_from_msi_on(host, opts) - expect(host['dist']).to be == 'puppet-agent-VERSION-x86' + expect(host['dist']).to eq 'puppet-agent-VERSION-x86' end it 'uses x86 msi when host is_x86_64 and install_32 is set on the options' do @@ -1015,7 +1015,7 @@ def stub_uninteresting_portions_of_install_puppetlabs_dev_repo! expect(subject).to receive(:install_a_puppet_msi_on).with(host, opts) subject.install_puppet_agent_from_msi_on(host, opts) - expect(host['dist']).to be == 'puppet-agent-VERSION-x86' + expect(host['dist']).to eq 'puppet-agent-VERSION-x86' end it 'uses x86 msi when host is_x86_64 and ruby_arch is x86 on the host' do @@ -1025,7 +1025,7 @@ def stub_uninteresting_portions_of_install_puppetlabs_dev_repo! expect(subject).to receive(:install_a_puppet_msi_on).with(host, opts) subject.install_puppet_agent_from_msi_on(host, opts) - expect(host['dist']).to be == 'puppet-agent-VERSION-x86' + expect(host['dist']).to eq 'puppet-agent-VERSION-x86' end it 'uses x86 msi when host !is_x86_64' do @@ -1033,7 +1033,7 @@ def stub_uninteresting_portions_of_install_puppetlabs_dev_repo! expect(subject).to receive(:install_a_puppet_msi_on).with(host, opts) subject.install_puppet_agent_from_msi_on(host, opts) - expect(host['dist']).to be == 'puppet-agent-VERSION-x86' + expect(host['dist']).to eq 'puppet-agent-VERSION-x86' end it 'uses x64 msi when host is_x86_64, no install_32 and ruby_arch != x86' do @@ -1041,7 +1041,7 @@ def stub_uninteresting_portions_of_install_puppetlabs_dev_repo! expect(subject).to receive(:install_a_puppet_msi_on).with(host, opts) subject.install_puppet_agent_from_msi_on(host, opts) - expect(host['dist']).to be == 'puppet-agent-VERSION-x64' + expect(host['dist']).to eq 'puppet-agent-VERSION-x64' end end