From 52eb303e57c49e0641239a006451f52413cfb51d Mon Sep 17 00:00:00 2001 From: Lukas Audzevicius Date: Wed, 17 Jan 2024 13:28:27 +0000 Subject: [PATCH 1/6] (CAT-1688) Upgrade rubocop Following a recent team decision, we are implementing a Rubocop Upgrade, moving the version from 1.48.1 to 1.50.0. This should be the final version until Puppet 7 is unsupported. --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 87b5862..3f6416e 100644 --- a/Gemfile +++ b/Gemfile @@ -31,7 +31,7 @@ group :development do gem "pry", '~> 0.10', require: false gem "simplecov-console", '~> 0.5', require: false gem "puppet-debugger", '~> 1.0', require: false - gem "rubocop", '= 1.48.1', require: false + gem "rubocop", '= 1.50.0', require: false gem "rubocop-performance", '= 1.16.0', require: false gem "rubocop-rspec", '= 2.19.0', require: false gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] From f0040a28e512a73f6a6b2faa0e2495310b592b7b Mon Sep 17 00:00:00 2001 From: Lukas Audzevicius Date: Wed, 17 Jan 2024 13:31:08 +0000 Subject: [PATCH 2/6] Enabling NewCops --- .rubocop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.rubocop.yml b/.rubocop.yml index 7ca9db4..7b5c386 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,6 +5,7 @@ require: - rubocop-performance - rubocop-rspec AllCops: + NewCops: enable DisplayCopNames: true TargetRubyVersion: '2.6' Include: From 18566dbf0f47d5292cc1e2b83e7e9f147aa0c02a Mon Sep 17 00:00:00 2001 From: Lukas Audzevicius Date: Wed, 17 Jan 2024 17:28:55 +0000 Subject: [PATCH 3/6] correcting safe offenses --- .rubocop_todo.yml | 92 +++++++++++++++++++++++++++++++------- tasks/abs.rb | 15 ++++--- tasks/docker.rb | 2 +- tasks/provision_service.rb | 10 ++--- tasks/vagrant.rb | 18 ++++---- 5 files changed, 99 insertions(+), 38 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3b2c6c2..6fc52a0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,30 +1,46 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2023-04-28 12:30:24 UTC using RuboCop version 1.48.1. +# on 2024-01-17 17:28:36 UTC using RuboCop version 1.50.0. # 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: 12 +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space +Layout/LineContinuationSpacing: + Exclude: + - 'tasks/docker.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: aligned, indented +Layout/LineEndStringConcatenationIndentation: + Exclude: + - 'tasks/docker.rb' + +# Offense count: 13 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: Max: 94 -# Offense count: 1 +# Offense count: 2 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 200 + Max: 155 -# Offense count: 9 +# Offense count: 8 # Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/CyclomaticComplexity: - Max: 25 + Max: 23 -# Offense count: 19 +# Offense count: 20 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: - Max: 69 + Max: 70 # Offense count: 3 # Configuration parameters: CountKeywordArgs, MaxOptionalParameters. @@ -34,7 +50,7 @@ Metrics/ParameterLists: # Offense count: 7 # Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/PerceivedComplexity: - Max: 30 + Max: 25 # Offense count: 2 # Configuration parameters: IgnoredMetadata. @@ -48,30 +64,74 @@ RSpec/DescribeClass: - 'spec/tasks/abs_spec.rb' - 'spec/unit/task_helper_spec.rb' -# Offense count: 4 +# Offense count: 12 # Configuration parameters: CountAsOne. RSpec/ExampleLength: - Max: 30 + Max: 27 -# Offense count: 6 +# Offense count: 13 RSpec/MultipleExpectations: Max: 13 -# Offense count: 2 +# Offense count: 6 # Configuration parameters: AllowSubject. RSpec/MultipleMemoizedHelpers: Max: 6 -# Offense count: 4 +# Offense count: 6 RSpec/StubbedMock: Exclude: - 'spec/tasks/abs_spec.rb' -# Offense count: 8 +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/CollectionCompact: + Exclude: + - 'tasks/vagrant.rb' + +# Offense count: 14 +# This cop supports safe autocorrection (--autocorrect). +Style/FileWrite: + Exclude: + - 'tasks/abs.rb' + - 'tasks/docker.rb' + - 'tasks/docker_exp.rb' + - 'tasks/provision_service.rb' + - 'tasks/update_node_pp.rb' + - 'tasks/update_site_pp.rb' + - 'tasks/vagrant.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedMethods. +# AllowedMethods: nonzero? +Style/IfWithBooleanLiteralBranches: + Exclude: + - 'tasks/vagrant.rb' + +# Offense count: 7 Style/MixinUsage: Exclude: - 'spec/spec_helper.rb' - 'tasks/docker.rb' - 'tasks/docker_exp.rb' - - 'tasks/provision_service.rb' + - 'tasks/vagrant.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/NegatedIfElseCondition: + Exclude: + - 'tasks/docker.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Methods. +Style/RedundantArgument: + Exclude: + - 'tasks/update_node_pp.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantStringEscape: + Exclude: - 'tasks/vagrant.rb' diff --git a/tasks/abs.rb b/tasks/abs.rb index 04e83a7..3562f84 100755 --- a/tasks/abs.rb +++ b/tasks/abs.rb @@ -26,11 +26,11 @@ def abs_host def provision(platform, inventory_location, vars) uri = URI.parse("https://#{abs_host}/api/v2/request") jenkins_build_url = if ENV['CI'] == 'true' && ENV['TRAVIS'] == 'true' - ENV['TRAVIS_JOB_WEB_URL'] + ENV.fetch('TRAVIS_JOB_WEB_URL', nil) elsif ENV['CI'] == 'True' && ENV['APPVEYOR'] == 'True' - "https://ci.appveyor.com/project/#{ENV['APPVEYOR_REPO_NAME']}/build/job/#{ENV['APPVEYOR_JOB_ID']}" + "https://ci.appveyor.com/project/#{ENV.fetch('APPVEYOR_REPO_NAME', nil)}/build/job/#{ENV.fetch('APPVEYOR_JOB_ID', nil)}" elsif ENV['GITHUB_ACTIONS'] == 'true' - "https://github.com/#{ENV['GITHUB_REPOSITORY']}/actions/runs/#{ENV['GITHUB_RUN_ID']}" + "https://github.com/#{ENV.fetch('GITHUB_REPOSITORY', nil)}/actions/runs/#{ENV.fetch('GITHUB_RUN_ID', nil)}" else 'https://litmus_manual' end @@ -91,17 +91,18 @@ def provision(platform, inventory_location, vars) data.each do |host| if platform_uses_ssh(host['type']) node = { 'uri' => host['hostname'], - 'config' => { 'transport' => 'ssh', 'ssh' => { 'user' => ENV['ABS_USER'], 'host-key-check' => false, 'connect-timeout' => 120 } }, + 'config' => { 'transport' => 'ssh', 'ssh' => { 'user' => ENV.fetch('ABS_USER', nil), 'host-key-check' => false, 'connect-timeout' => 120 } }, 'facts' => { 'provisioner' => 'abs', 'platform' => host['type'], 'job_id' => job_id } } if !ENV['ABS_SSH_PRIVATE_KEY'].nil? && !ENV['ABS_SSH_PRIVATE_KEY'].empty? - node['config']['ssh']['private-key'] = ENV['ABS_SSH_PRIVATE_KEY'] + node['config']['ssh']['private-key'] = ENV.fetch('ABS_SSH_PRIVATE_KEY', nil) else - node['config']['ssh']['password'] = ENV['ABS_PASSWORD'] + node['config']['ssh']['password'] = ENV.fetch('ABS_PASSWORD', nil) end group_name = 'ssh_nodes' else node = { 'uri' => host['hostname'], - 'config' => { 'transport' => 'winrm', 'winrm' => { 'user' => ENV['ABS_WIN_USER'], 'password' => ENV['ABS_PASSWORD'], 'ssl' => false, 'connect-timeout' => 120 } }, + 'config' => { 'transport' => 'winrm', + 'winrm' => { 'user' => ENV.fetch('ABS_WIN_USER', nil), 'password' => ENV.fetch('ABS_PASSWORD', nil), 'ssl' => false, 'connect-timeout' => 120 } }, 'facts' => { 'provisioner' => 'abs', 'platform' => host['type'], 'job_id' => job_id } } group_name = 'winrm_nodes' end diff --git a/tasks/docker.rb b/tasks/docker.rb index 446d7d7..3343cad 100755 --- a/tasks/docker.rb +++ b/tasks/docker.rb @@ -161,7 +161,7 @@ def provision(image, inventory_location, vars) distro = os_release_facts['ID'] version = os_release_facts['VERSION_ID'] - hostname = (ENV['DOCKER_HOST'].nil? || ENV['DOCKER_HOST'].empty?) ? 'localhost' : URI.parse(ENV['DOCKER_HOST']).host || ENV['DOCKER_HOST'] + hostname = (ENV['DOCKER_HOST'].nil? || ENV['DOCKER_HOST'].empty?) ? 'localhost' : URI.parse(ENV.fetch('DOCKER_HOST', nil)).host || ENV.fetch('DOCKER_HOST', nil) begin # Use the current docker context to determine the docker hostname docker_context = JSON.parse(run_local_command('docker context inspect'))[0] diff --git a/tasks/provision_service.rb b/tasks/provision_service.rb index b0dc8fb..b0df15b 100755 --- a/tasks/provision_service.rb +++ b/tasks/provision_service.rb @@ -46,7 +46,7 @@ def invoke_cloud_request(params, uri, job_url, verb, retry_attempts) request.body = if job_url { url: job_url, VMs: machines }.to_json else - { github_token: ENV['GITHUB_TOKEN'], VMs: machines }.to_json + { github_token: ENV.fetch('GITHUB_TOKEN', nil), VMs: machines }.to_json end when 'delete' request = Net::HTTP::Delete.new(uri, headers) @@ -89,14 +89,14 @@ def provision(platform, inventory_location, vars, retry_attempts) # Call the provision service with the information necessary and write the inventory file locally if ENV['GITHUB_RUN_ID'] - job_url = ENV['GITHUB_URL'] || "https://api.github.com/repos/#{ENV['GITHUB_REPOSITORY']}/actions/runs/#{ENV['GITHUB_RUN_ID']}" + job_url = ENV['GITHUB_URL'] || "https://api.github.com/repos/#{ENV.fetch('GITHUB_REPOSITORY', nil)}/actions/runs/#{ENV['GITHUB_RUN_ID']}" else puts 'Using GITHUB_TOKEN as no GITHHUB_RUN_ID found' end uri = URI.parse(ENV['SERVICE_URL'] || default_uri) - cloud = ENV['CLOUD'] - region = ENV['REGION'] - zone = ENV['ZONE'] + cloud = ENV.fetch('CLOUD', nil) + region = ENV.fetch('REGION', nil) + zone = ENV.fetch('ZONE', nil) if job_url.nil? && vars data = JSON.parse(vars.tr(';', ',')) job_url = data['job_url'] diff --git a/tasks/vagrant.rb b/tasks/vagrant.rb index 3df7636..685773f 100755 --- a/tasks/vagrant.rb +++ b/tasks/vagrant.rb @@ -213,18 +213,18 @@ def tear_down(node_name, inventory_location) action = params['action'] node_name = params['node_name'] inventory_location = sanitise_inventory_location(params['inventory']) -enable_synced_folder = params['enable_synced_folder'].nil? ? ENV['VAGRANT_ENABLE_SYNCED_FOLDER'] : params['enable_synced_folder'] +enable_synced_folder = params['enable_synced_folder'].nil? ? ENV.fetch('VAGRANT_ENABLE_SYNCED_FOLDER', nil) : params['enable_synced_folder'] if enable_synced_folder.is_a?(String) enable_synced_folder = enable_synced_folder.casecmp('true').zero? ? true : false end -provider = params['provider'].nil? ? ENV['VAGRANT_PROVIDER'] : params['provider'] -cpus = params['cpus'].nil? ? ENV['VAGRANT_CPUS'] : params['cpus'] -memory = params['memory'].nil? ? ENV['VAGRANT_MEMORY'] : params['memory'] -hyperv_vswitch = params['hyperv_vswitch'].nil? ? ENV['VAGRANT_HYPERV_VSWITCH'] : params['hyperv_vswitch'] -hyperv_smb_username = params['hyperv_smb_username'].nil? ? ENV['VAGRANT_HYPERV_SMB_USERNAME'] : params['hyperv_smb_username'] -hyperv_smb_password = params['hyperv_smb_password'].nil? ? ENV['VAGRANT_HYPERV_SMB_PASSWORD'] : params['hyperv_smb_password'] -box_url = params['box_url'].nil? ? ENV['VAGRANT_BOX_URL'] : params['box_url'] -password = params['password'].nil? ? ENV['VAGRANT_PASSWORD'] : params['password'] +provider = params['provider'].nil? ? ENV.fetch('VAGRANT_PROVIDER', nil) : params['provider'] +cpus = params['cpus'].nil? ? ENV.fetch('VAGRANT_CPUS', nil) : params['cpus'] +memory = params['memory'].nil? ? ENV.fetch('VAGRANT_MEMORY', nil) : params['memory'] +hyperv_vswitch = params['hyperv_vswitch'].nil? ? ENV.fetch('VAGRANT_HYPERV_VSWITCH', nil) : params['hyperv_vswitch'] +hyperv_smb_username = params['hyperv_smb_username'].nil? ? ENV.fetch('VAGRANT_HYPERV_SMB_USERNAME', nil) : params['hyperv_smb_username'] +hyperv_smb_password = params['hyperv_smb_password'].nil? ? ENV.fetch('VAGRANT_HYPERV_SMB_PASSWORD', nil) : params['hyperv_smb_password'] +box_url = params['box_url'].nil? ? ENV.fetch('VAGRANT_BOX_URL', nil) : params['box_url'] +password = params['password'].nil? ? ENV.fetch('VAGRANT_PASSWORD', nil) : params['password'] raise 'specify a node_name when tearing down' if action == 'tear_down' && node_name.nil? raise 'specify a platform when provisioning' if action == 'provision' && platform.nil? From 84999d16758cfa0dc3eca79277d215dc65ba081b Mon Sep 17 00:00:00 2001 From: Lukas Audzevicius Date: Wed, 17 Jan 2024 18:13:38 +0000 Subject: [PATCH 4/6] more safe autocorrections --- .rubocop_todo.yml | 28 ---------------------------- tasks/docker.rb | 22 +++++++++++----------- tasks/vagrant.rb | 2 +- 3 files changed, 12 insertions(+), 40 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6fc52a0..033a281 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,22 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, no_space -Layout/LineContinuationSpacing: - Exclude: - - 'tasks/docker.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: aligned, indented -Layout/LineEndStringConcatenationIndentation: - Exclude: - - 'tasks/docker.rb' - # Offense count: 13 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: @@ -117,21 +101,9 @@ Style/MixinUsage: - 'tasks/docker_exp.rb' - 'tasks/vagrant.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/NegatedIfElseCondition: - Exclude: - - 'tasks/docker.rb' - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Methods. Style/RedundantArgument: Exclude: - 'tasks/update_node_pp.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantStringEscape: - Exclude: - - 'tasks/vagrant.rb' diff --git a/tasks/docker.rb b/tasks/docker.rb index 3343cad..d55603c 100755 --- a/tasks/docker.rb +++ b/tasks/docker.rb @@ -23,16 +23,16 @@ def install_ssh_components(distro, version, container) # sometimes the redhat 6 variant containers like to eat their rpmdb, leading to # issues with "rpmdb: unable to join the environment" errors # This "fix" is from https://www.srv24x7.com/criticalyum-main-error-rpmdb-open-failed/ - run_local_command("docker exec #{container} bash -exc \"rm -f /var/lib/rpm/__db*; "\ - 'db_verify /var/lib/rpm/Packages; '\ - 'rpm --rebuilddb; '\ - 'yum clean all; '\ - 'yum install -y sudo openssh-server openssh-clients"') + run_local_command("docker exec #{container} bash -exc \"rm -f /var/lib/rpm/__db*; " \ + 'db_verify /var/lib/rpm/Packages; ' \ + 'rpm --rebuilddb; ' \ + 'yum clean all; ' \ + 'yum install -y sudo openssh-server openssh-clients"') else # If systemd is running for init, ensure systemd has finished starting up before proceeding: - check_init_cmd = 'if [[ "$(readlink /proc/1/exe)" == "/usr/lib/systemd/systemd" ]]; then '\ - 'count=0 ; while ! [[ "$(systemctl is-system-running)" =~ ^running|degraded$ && $count > 20 ]]; '\ - 'do sleep 0.1 ; count=$((count+1)) ; done ; fi' + check_init_cmd = 'if [[ "$(readlink /proc/1/exe)" == "/usr/lib/systemd/systemd" ]]; then ' \ + 'count=0 ; while ! [[ "$(systemctl is-system-running)" =~ ^running|degraded$ && $count > 20 ]]; ' \ + 'do sleep 0.1 ; count=$((count+1)) ; done ; fi' run_local_command("docker exec #{container} bash -c '#{check_init_cmd}'") run_local_command("docker exec #{container} yum install -y sudo openssh-server openssh-clients") end @@ -74,10 +74,10 @@ def fix_ssh(distro, version, container) # https://bugzilla.redhat.com/show_bug.cgi?id=1728777 run_local_command("docker exec #{container} sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd") if distro =~ %r{redhat|centos} && version =~ %r{^7} - if !%r{^(7|8|9|2)}.match?(version) - run_local_command("docker exec #{container} service sshd restart") - else + if %r{^(7|8|9|2)}.match?(version) run_local_command("docker exec #{container} /usr/sbin/sshd") + else + run_local_command("docker exec #{container} service sshd restart") end when %r{sles} run_local_command("docker exec #{container} /usr/sbin/sshd") diff --git a/tasks/vagrant.rb b/tasks/vagrant.rb index 685773f..c63ec44 100755 --- a/tasks/vagrant.rb +++ b/tasks/vagrant.rb @@ -54,7 +54,7 @@ def generate_vagrantfile(file_path, platform, enable_synced_folder, provider, cp '' end vf = <<~VF - Vagrant.configure(\"2\") do |config| + Vagrant.configure("2") do |config| config.vm.box = '#{platform}' config.vm.boot_timeout = 600 config.ssh.insert_key = false From 75158963c77d69a6ce3b0342237af8429d271669 Mon Sep 17 00:00:00 2001 From: Lukas Audzevicius Date: Thu, 18 Jan 2024 13:58:12 +0000 Subject: [PATCH 5/6] Correcting unsafe offenses --- .rubocop_todo.yml | 21 --------------------- tasks/update_node_pp.rb | 2 +- tasks/vagrant.rb | 6 ++---- 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 033a281..6bccda1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -67,12 +67,6 @@ RSpec/StubbedMock: Exclude: - 'spec/tasks/abs_spec.rb' -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/CollectionCompact: - Exclude: - - 'tasks/vagrant.rb' - # Offense count: 14 # This cop supports safe autocorrection (--autocorrect). Style/FileWrite: @@ -85,14 +79,6 @@ Style/FileWrite: - 'tasks/update_site_pp.rb' - 'tasks/vagrant.rb' -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AllowedMethods. -# AllowedMethods: nonzero? -Style/IfWithBooleanLiteralBranches: - Exclude: - - 'tasks/vagrant.rb' - # Offense count: 7 Style/MixinUsage: Exclude: @@ -100,10 +86,3 @@ Style/MixinUsage: - 'tasks/docker.rb' - 'tasks/docker_exp.rb' - 'tasks/vagrant.rb' - -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: Methods. -Style/RedundantArgument: - Exclude: - - 'tasks/update_node_pp.rb' diff --git a/tasks/update_node_pp.rb b/tasks/update_node_pp.rb index 266e8b9..02b41b9 100755 --- a/tasks/update_node_pp.rb +++ b/tasks/update_node_pp.rb @@ -17,7 +17,7 @@ def update_file(manifest, target_node) # remove the last bracket in the manifest existing_manifest.pop existing_manifest.push("\n #{manifest}\n}") - final_manifest = existing_manifest.join('') + final_manifest = existing_manifest.join else final_manifest = "node '#{target_node}' \n{\n #{manifest} \n}" end diff --git a/tasks/vagrant.rb b/tasks/vagrant.rb index c63ec44..07c81e6 100755 --- a/tasks/vagrant.rb +++ b/tasks/vagrant.rb @@ -86,7 +86,7 @@ def configure_remoting(platform, remoting_config_path, password) keys: remoting_config['identityfile'], password: password, verbose: :debug - }.reject { |_k, v| v.nil? } + }.compact Net::SSH.start( remoting_config['hostname'], remoting_config['user'], @@ -214,9 +214,7 @@ def tear_down(node_name, inventory_location) node_name = params['node_name'] inventory_location = sanitise_inventory_location(params['inventory']) enable_synced_folder = params['enable_synced_folder'].nil? ? ENV.fetch('VAGRANT_ENABLE_SYNCED_FOLDER', nil) : params['enable_synced_folder'] -if enable_synced_folder.is_a?(String) - enable_synced_folder = enable_synced_folder.casecmp('true').zero? ? true : false -end +enable_synced_folder = enable_synced_folder.casecmp('true').zero? if enable_synced_folder.is_a?(String) provider = params['provider'].nil? ? ENV.fetch('VAGRANT_PROVIDER', nil) : params['provider'] cpus = params['cpus'].nil? ? ENV.fetch('VAGRANT_CPUS', nil) : params['cpus'] memory = params['memory'].nil? ? ENV.fetch('VAGRANT_MEMORY', nil) : params['memory'] From 52f278bd203205647314be8d1ef77d2d1d4b5c28 Mon Sep 17 00:00:00 2001 From: Lukas Audzevicius Date: Thu, 18 Jan 2024 14:07:19 +0000 Subject: [PATCH 6/6] config adjustments --- .rubocop.yml | 3 +++ .rubocop_todo.yml | 12 ------------ Gemfile | 2 +- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 7b5c386..1f41814 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -82,3 +82,6 @@ Style/Documentation: - spec/**/* Style/WordArray: EnforcedStyle: brackets +Style/FileWrite: + Description: Enforcing this rule might break the code in unexpected ways. + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6bccda1..22ced2d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -67,18 +67,6 @@ RSpec/StubbedMock: Exclude: - 'spec/tasks/abs_spec.rb' -# Offense count: 14 -# This cop supports safe autocorrection (--autocorrect). -Style/FileWrite: - Exclude: - - 'tasks/abs.rb' - - 'tasks/docker.rb' - - 'tasks/docker_exp.rb' - - 'tasks/provision_service.rb' - - 'tasks/update_node_pp.rb' - - 'tasks/update_site_pp.rb' - - 'tasks/vagrant.rb' - # Offense count: 7 Style/MixinUsage: Exclude: diff --git a/Gemfile b/Gemfile index 3f6416e..4ea5596 100644 --- a/Gemfile +++ b/Gemfile @@ -31,7 +31,7 @@ group :development do gem "pry", '~> 0.10', require: false gem "simplecov-console", '~> 0.5', require: false gem "puppet-debugger", '~> 1.0', require: false - gem "rubocop", '= 1.50.0', require: false + gem "rubocop", '~> 1.50.0', require: false gem "rubocop-performance", '= 1.16.0', require: false gem "rubocop-rspec", '= 2.19.0', require: false gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw]