diff --git a/.rubocop.yml b/.rubocop.yml index f9cf639c7..84c118c0b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,6 @@ --- +inherit_from: .rubocop_todo.yml + inherit_gem: voxpupuli-test: rubocop.yml diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 000000000..b9e5cd743 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,27 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2023-08-17 21:33:46 UTC using RuboCop version 1.50.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 +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 9 +# This cop supports unsafe autocorrection (--autocorrect-all). +RSpec/BeEq: + Exclude: + - 'spec/unit/puppet/provider/jenkins_job/cli_spec.rb' + - 'spec/unit/puppet/x/jenkins/provider/cli_spec.rb' + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: . +# SupportedStyles: constant, string +RSpec/VerifiedDoubleReference: + EnforcedStyle: string + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/SlicingWithRange: + Exclude: + - 'lib/puppet/jenkins/plugins.rb' diff --git a/lib/puppet/parser/functions/jenkins_port.rb b/lib/puppet/parser/functions/jenkins_port.rb index ce060846c..3461b050b 100644 --- a/lib/puppet/parser/functions/jenkins_port.rb +++ b/lib/puppet/parser/functions/jenkins_port.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Puppet::Parser::Functions - newfunction(:jenkins_port, type: :rvalue, doc: <<-'ENDHEREDOC') do |_args| + newfunction(:jenkins_port, type: :rvalue, doc: <<-ENDHEREDOC) do |_args| Return the configurad Jenkins port value (corresponds to /etc/defaults/jenkins -> JENKINS_PORT diff --git a/lib/puppet/parser/functions/jenkins_prefix.rb b/lib/puppet/parser/functions/jenkins_prefix.rb index c0f5f9747..80a6a55bd 100644 --- a/lib/puppet/parser/functions/jenkins_prefix.rb +++ b/lib/puppet/parser/functions/jenkins_prefix.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Puppet::Parser::Functions - newfunction(:jenkins_prefix, type: :rvalue, doc: <<-'ENDHEREDOC') do |_args| + newfunction(:jenkins_prefix, type: :rvalue, doc: <<-ENDHEREDOC) do |_args| Return the configured Jenkins prefix value (corresponds to /etc/defaults/jenkins -> PREFIX) diff --git a/lib/puppet/provider/jenkins_authorization_strategy/cli.rb b/lib/puppet/provider/jenkins_authorization_strategy/cli.rb index 950d7a966..71dcc2c3e 100644 --- a/lib/puppet/provider/jenkins_authorization_strategy/cli.rb +++ b/lib/puppet/provider/jenkins_authorization_strategy/cli.rb @@ -76,7 +76,6 @@ def self.get_authorization_strategy(catalog = nil) end private_class_method :get_authorization_strategy - # rubocop:disable Naming/AccessorMethodName def set_jenkins_instance(input = nil) input ||= to_hash @@ -91,5 +90,4 @@ def set_strategy_unsecured } set_jenkins_instance(input) end - # rubocop:enable Naming/AccessorMethodName end diff --git a/lib/puppet/provider/jenkins_security_realm/cli.rb b/lib/puppet/provider/jenkins_security_realm/cli.rb index 098174240..f5f25648b 100644 --- a/lib/puppet/provider/jenkins_security_realm/cli.rb +++ b/lib/puppet/provider/jenkins_security_realm/cli.rb @@ -77,7 +77,6 @@ def self.get_security_realm(catalog = nil) end private_class_method :get_security_realm - # rubocop:disable Naming/AccessorMethodName def set_jenkins_instance(input = nil) input ||= to_hash @@ -92,5 +91,4 @@ def set_security_none } set_jenkins_instance(input) end - # rubocop:enable Naming/AccessorMethodName end diff --git a/spec/acceptance/job_spec.rb b/spec/acceptance/job_spec.rb index bf56c3d9d..b34c8e59f 100644 --- a/spec/acceptance/job_spec.rb +++ b/spec/acceptance/job_spec.rb @@ -4,7 +4,7 @@ describe 'jenkins::job' do let(:test_build_job) do - example = <<~'EOS' + example = <<~EOS @@ -39,7 +39,7 @@ # the historical assumption is that this will work without cli => true # set on the jenkins class jenkins::job { 'test-build-job': - config => \'#{test_build_job}\', + config => '#{test_build_job}', } EOS @@ -65,14 +65,14 @@ pp_create = <<-EOS include jenkins jenkins::job {'test-noreplace-job': - config => \'#{test_build_job.gsub('test job', 'do not overwrite me')}\', + config => '#{test_build_job.gsub('test job', 'do not overwrite me')}', } EOS pp_update = <<-EOS include jenkins jenkins::job {'test-noreplace-job': - config => \'#{test_build_job}\', + config => '#{test_build_job}', replace => false, } EOS @@ -97,7 +97,7 @@ pp = <<-EOS include jenkins jenkins::job { 'test-build-job': - config => \'#{test_build_job}\', + config => '#{test_build_job}', } EOS @@ -108,7 +108,7 @@ include jenkins jenkins::job { 'test-build-job': ensure => 'absent', - config => \'#{test_build_job}\', + config => '#{test_build_job}', } EOS diff --git a/spec/acceptance/plugin_spec.rb b/spec/acceptance/plugin_spec.rb index c3785a6ff..8631bb338 100644 --- a/spec/acceptance/plugin_spec.rb +++ b/spec/acceptance/plugin_spec.rb @@ -96,7 +96,7 @@ class {'jenkins': end end - describe command("unzip -p #{PDIR}/jquery3-api.hpi META-INF/MANIFEST.MF | sed 's/Plugin-Version: \\\(.*\\\)/\\1/;tx;d;:x'") do + describe command("unzip -p #{PDIR}/jquery3-api.hpi META-INF/MANIFEST.MF | sed 's/Plugin-Version: \\(.*\\)/\\1/;tx;d;:x'") do its(:stdout) { is_expected.to eq("3.6.0-3\n") } end diff --git a/spec/acceptance/xtypes/jenkins_job_spec.rb b/spec/acceptance/xtypes/jenkins_job_spec.rb index 49bf074e8..21e9d8c99 100644 --- a/spec/acceptance/xtypes/jenkins_job_spec.rb +++ b/spec/acceptance/xtypes/jenkins_job_spec.rb @@ -6,7 +6,7 @@ # on existing state as a performance optimization. describe 'jenkins_job', order: :defined do let(:test_build_job) do - example = <<~'EOS' + example = <<~EOS @@ -34,7 +34,7 @@ end let(:test_folder_job) do - example = <<~'EOS' + example = <<~EOS @@ -65,7 +65,7 @@ include jenkins::cli::config jenkins_job { 'foo': ensure => present, - config => \'#{test_build_job}\', + config => '#{test_build_job}', } EOS @@ -118,17 +118,17 @@ #{manifest} jenkins_job { 'foo': ensure => present, - config => \'#{test_folder_job}\', + config => '#{test_folder_job}', } jenkins_job { 'foo/bar': ensure => present, - config => \'#{test_folder_job}\', + config => '#{test_folder_job}', } jenkins_job { 'foo/bar/baz': ensure => present, - config => \'#{test_build_job}\', + config => '#{test_build_job}', } EOS @@ -190,7 +190,7 @@ #{super()} jenkins_job { 'foo': ensure => present, - config => \'#{test_build_job}\', + config => '#{test_build_job}', } PUPPET end @@ -204,7 +204,7 @@ #{super()} jenkins_job { 'foo': ensure => present, - config => \'#{test_folder_job}\', + config => '#{test_folder_job}', } PUPPET end diff --git a/spec/defines/jenkins_credentials_spec.rb b/spec/defines/jenkins_credentials_spec.rb index d0c9b0623..31496d89f 100644 --- a/spec/defines/jenkins_credentials_spec.rb +++ b/spec/defines/jenkins_credentials_spec.rb @@ -38,7 +38,7 @@ it { is_expected.to contain_jenkins__cli__exec('create-jenkins-credentials-foo').with(command: ['create_or_update_credentials', title.to_s, "'mypass'", "''", "'Managed by Puppet'", "''"], - unless: "for i in \$(seq 1 10); do \$HELPER_CMD credential_info #{title} && break || sleep 10; done | grep #{title}") + unless: "for i in $(seq 1 10); do $HELPER_CMD credential_info #{title} && break || sleep 10; done | grep #{title}") } end @@ -65,7 +65,7 @@ it { is_expected.to contain_jenkins__cli__exec('create-jenkins-credentials-foo').with(command: ['create_or_update_credentials', title.to_s, "'mypass'", "'e94d3b98-5ba4-43b9-89ed-79a08ea97f6f'", "'Managed by Puppet'", "''"], - unless: "for i in \$(seq 1 10); do \$HELPER_CMD credential_info #{title} && break || sleep 10; done | grep #{title}") + unless: "for i in $(seq 1 10); do $HELPER_CMD credential_info #{title} && break || sleep 10; done | grep #{title}") } end end diff --git a/spec/unit/puppet/x/jenkins/config_spec.rb b/spec/unit/puppet/x/jenkins/config_spec.rb index 186b5585d..02221d7d1 100644 --- a/spec/unit/puppet/x/jenkins/config_spec.rb +++ b/spec/unit/puppet/x/jenkins/config_spec.rb @@ -56,7 +56,7 @@ # we are relying on a side effect of this method being to test features / # load libs describe '#initialize' do - it { expect(described_class.new).to be_kind_of described_class } + it { expect(described_class.new).to be_a described_class } end describe '#[]' do diff --git a/spec/unit/puppet/x/spec_jenkins_providers.rb b/spec/unit/puppet/x/spec_jenkins_providers.rb index 4bfefe9e2..4e144433d 100644 --- a/spec/unit/puppet/x/spec_jenkins_providers.rb +++ b/spec/unit/puppet/x/spec_jenkins_providers.rb @@ -15,7 +15,7 @@ context 'feature :retries' do it do expect(confines).to include( - be_kind_of(Puppet::Confine::Feature). + be_a(Puppet::Confine::Feature). and(have_attributes(values: [:retries])) ) end @@ -24,7 +24,7 @@ context 'commands :java' do it do expect(confines).to include( - be_kind_of(Puppet::Confine::Exists). + be_a(Puppet::Confine::Exists). and(have_attributes(values: ['java'])) ) end