From 7201c6d3c3c4ad7cca64b2e90115ec311980cf3a Mon Sep 17 00:00:00 2001 From: david22swan Date: Tue, 30 Sep 2025 15:22:43 +0100 Subject: [PATCH 1/3] (CAT-2453) Bump Rubocop versions in order to remove rexml The version of rexml brought in by the current rubocop versions has a security vulnerability. Updating to these rubocop versions will remove their dependency entirely. Adding in plugins that where previously part of the default package, but have been split off since our previously used version. --- .rubocop.yml | 33 ++++++++++++++++++--------------- Gemfile | 9 ++++++--- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index c773d1b6..14406709 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,7 +1,10 @@ --- -require: -- rubocop-performance -- rubocop-rspec +plugins: + - rubocop-rspec + - rubocop-rspec_rails + - rubocop-performance + - rubocop-factory_bot + - rubocop-capybara AllCops: NewCops: enable DisplayCopNames: true @@ -294,7 +297,7 @@ Performance/UriDefaultParser: Enabled: false RSpec/Be: Enabled: false -RSpec/Capybara/FeatureMethods: +RSpec/Dialect: Enabled: false RSpec/ContainExactly: Enabled: false @@ -320,11 +323,11 @@ RSpec/ExpectChange: Enabled: false RSpec/ExpectInHook: Enabled: false -RSpec/FactoryBot/AttributeDefinedStatically: +FactoryBot/AttributeDefinedStatically: Enabled: false -RSpec/FactoryBot/CreateList: +FactoryBot/CreateList: Enabled: false -RSpec/FactoryBot/FactoryClassName: +FactoryBot/FactoryClassName: Enabled: false RSpec/HooksBeforeExamples: Enabled: false @@ -600,11 +603,11 @@ RSpec/DuplicatedMetadata: Enabled: false RSpec/ExcessiveDocstringSpacing: Enabled: false -RSpec/FactoryBot/ConsistentParenthesesStyle: +FactoryBot/ConsistentParenthesesStyle: Enabled: false -RSpec/FactoryBot/FactoryNameStyle: +FactoryBot/FactoryNameStyle: Enabled: false -RSpec/FactoryBot/SyntaxMethods: +FactoryBot/SyntaxMethods: Enabled: false RSpec/IdenticalEqualityAssertion: Enabled: false @@ -612,15 +615,15 @@ RSpec/NoExpectationExample: Enabled: false RSpec/PendingWithoutReason: Enabled: false -RSpec/Rails/AvoidSetupHook: +RSpecRails/AvoidSetupHook: Enabled: false -RSpec/Rails/HaveHttpStatus: +RSpecRails/HaveHttpStatus: Enabled: false -RSpec/Rails/InferredSpecType: +RSpecRails/InferredSpecType: Enabled: false -RSpec/Rails/MinitestAssertions: +RSpecRails/MinitestAssertions: Enabled: false -RSpec/Rails/TravelAround: +RSpecRails/TravelAround: Enabled: false RSpec/RedundantAround: Enabled: false diff --git a/Gemfile b/Gemfile index bdbd40c2..c407c11e 100644 --- a/Gemfile +++ b/Gemfile @@ -27,9 +27,12 @@ group :development do gem "pry", '~> 0.10', require: false gem "simplecov-console", '~> 0.9', require: false gem "puppet-debugger", '~> 1.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 "rubocop", '~> 1.73.0', require: false + gem "rubocop-performance", '~> 1.24.0', require: false + gem "rubocop-rspec", '~> 3.5.0', require: false + gem 'rubocop-rspec_rails', '~> 2.31.0', require: false + gem 'rubocop-factory_bot', '~> 2.27.0', require: false + gem 'rubocop-capybara', '~> 2.22.0', require: false gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] gem "github_changelog_generator", require: false gem "ruby-pwsh", require: false From 48fc561396f3e320fcae6e3e12c64e39b495697a Mon Sep 17 00:00:00 2001 From: david22swan Date: Tue, 30 Sep 2025 15:23:11 +0100 Subject: [PATCH 2/3] (RUBOCOP) Autocorrect --- lib/puppet/type/dsc.rb | 2 +- .../basic_functionality/negative/dsc_on_linux_spec.rb | 1 + spec/spec_helper.rb | 2 +- spec/unit/puppet_x/dsc_lite/dsc_type_helpers_spec.rb | 1 - spec/unit/puppet_x/dsc_lite/powershell_hash_formatter_spec.rb | 1 - 5 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/puppet/type/dsc.rb b/lib/puppet/type/dsc.rb index 5030fad2..c72d0937 100644 --- a/lib/puppet/type/dsc.rb +++ b/lib/puppet/type/dsc.rb @@ -45,7 +45,7 @@ def change_to_s(currentvalue, newvalue) if currentvalue == :absent || currentvalue.nil? _("invoked #{resource.parameters[:module].value}\\#{resource.parameters[:resource_name].value}") else - super(currentvalue, newvalue) + super end end end diff --git a/spec/acceptance/basic_functionality/negative/dsc_on_linux_spec.rb b/spec/acceptance/basic_functionality/negative/dsc_on_linux_spec.rb index f42e9704..f55afb55 100755 --- a/spec/acceptance/basic_functionality/negative/dsc_on_linux_spec.rb +++ b/spec/acceptance/basic_functionality/negative/dsc_on_linux_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # NOTE: this is a master/agent test that does not run with Litmus. # require 'spec_helper_acceptance' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ae7c1f68..2f7fdae3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -26,7 +26,7 @@ begin require 'deep_merge' - default_facts.deep_merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true)) + default_facts.deep_merge!(YAML.safe_load_file(f, permitted_classes: [], permitted_symbols: [], aliases: true)) rescue StandardError => e RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" end diff --git a/spec/unit/puppet_x/dsc_lite/dsc_type_helpers_spec.rb b/spec/unit/puppet_x/dsc_lite/dsc_type_helpers_spec.rb index 179ab5f6..b5dae962 100644 --- a/spec/unit/puppet_x/dsc_lite/dsc_type_helpers_spec.rb +++ b/spec/unit/puppet_x/dsc_lite/dsc_type_helpers_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -# rubocop:disable RSpec/FilePath require 'spec_helper' require 'puppet_x/puppetlabs/dsc_lite/dsc_type_helpers' diff --git a/spec/unit/puppet_x/dsc_lite/powershell_hash_formatter_spec.rb b/spec/unit/puppet_x/dsc_lite/powershell_hash_formatter_spec.rb index e91c77c7..cc0ae37a 100644 --- a/spec/unit/puppet_x/dsc_lite/powershell_hash_formatter_spec.rb +++ b/spec/unit/puppet_x/dsc_lite/powershell_hash_formatter_spec.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -# rubocop:disable RSpec/FilePath require 'spec_helper' require 'puppet_x' require 'puppet_x/puppetlabs/dsc_lite/powershell_hash_formatter' From 3e7130696ab74c8093ff0ad7b6957a0bdd3eda06 Mon Sep 17 00:00:00 2001 From: david22swan Date: Tue, 30 Sep 2025 15:23:53 +0100 Subject: [PATCH 3/3] (RUBOCOP) Todo regenerated --- .rubocop.yml | 2 + .rubocop_todo.yml | 170 ++-------------------------------------------- 2 files changed, 8 insertions(+), 164 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 14406709..c3409f41 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,6 @@ --- +inherit_from: .rubocop_todo.yml + plugins: - rubocop-rspec - rubocop-rspec_rails diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6eee0d9b..c87dc433 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,180 +1,22 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-06-07 10:17:46 UTC using RuboCop version 1.50.2. +# on 2025-09-30 14:23:25 UTC using RuboCop version 1.73.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: 2 -# Configuration parameters: AllowedMethods. -# AllowedMethods: enums -Lint/ConstantDefinitionInBlock: +# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. +# Include: **/*_spec.rb +RSpec/SpecFilePathFormat: Exclude: - - 'lib/puppet/provider/base_dsc_lite/powershell.rb' - - 'spec/acceptance/unicode/puppet_apply_utf8_file_name_spec.rb' - -# Offense count: 2 -# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches. -Lint/DuplicateBranch: - Exclude: - - 'spec/spec_helper_acceptance_local.rb' - -# Offense count: 1 -# Configuration parameters: AllowComments. -Lint/EmptyFile: - Exclude: - - 'spec/spec_helper_local.rb' - -# Offense count: 4 -# Configuration parameters: MaximumRangeSize. -Lint/MissingCopEnableDirective: - Exclude: - - 'lib/puppet_x/puppetlabs/dsc_lite/dsc_type_helpers.rb' - - 'lib/puppet_x/puppetlabs/dsc_lite/powershell_hash_formatter.rb' + - '**/spec/routing/**/*' - 'spec/unit/puppet_x/dsc_lite/dsc_type_helpers_spec.rb' - 'spec/unit/puppet_x/dsc_lite/powershell_hash_formatter_spec.rb' -# Offense count: 6 -# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. -Metrics/AbcSize: - Max: 78 - -# Offense count: 2 -# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. -# AllowedMethods: refine -Metrics/BlockLength: - Max: 134 - -# Offense count: 1 -# Configuration parameters: CountComments, CountAsOne. -Metrics/ClassLength: - Max: 111 - -# Offense count: 4 -# Configuration parameters: AllowedMethods, AllowedPatterns. -Metrics/CyclomaticComplexity: - Max: 31 - -# Offense count: 10 -# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. -Metrics/MethodLength: - Max: 40 - -# Offense count: 4 -# Configuration parameters: AllowedMethods, AllowedPatterns. -Metrics/PerceivedComplexity: - Max: 28 - -# Offense count: 1 -# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. -# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to -Naming/MethodParameterName: - Exclude: - - 'lib/puppet_x/puppetlabs/dsc_lite/dsc_type_helpers.rb' - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). -Performance/RedundantEqualityComparisonBlock: +Style/BitwisePredicate: Exclude: - - 'lib/puppet_x/puppetlabs/dsc_lite/dsc_type_helpers.rb' - -# Offense count: 12 -# Configuration parameters: Prefixes, AllowedPatterns. -# Prefixes: when, with, without -RSpec/ContextWording: - Exclude: - - 'spec/acceptance/basic_functionality/puppet_apply_dsc_manifest_spec.rb' - - 'spec/acceptance/dsc_type/custom_resource_from_system_psmodulepath_spec.rb' - - 'spec/acceptance/dsc_type/custom_resource_path_spec.rb' - - 'spec/acceptance/dsc_type/multiple_dsc_resources_in_psmodulepath_spec.rb' - - 'spec/acceptance/dsc_type/psdesiredstateconfiguration_spec.rb' - - 'spec/acceptance/reboot/negative/reboot_graph_cycle_spec.rb' - - 'spec/acceptance/reboot/reboot_no_invoke_warning_spec.rb' - - 'spec/acceptance/unicode/puppet_apply_utf8_file_name_spec.rb' - -# Offense count: 11 -# Configuration parameters: IgnoredMetadata. -RSpec/DescribeClass: - Exclude: - - '**/spec/features/**/*' - - '**/spec/requests/**/*' - - '**/spec/routing/**/*' - - '**/spec/system/**/*' - - '**/spec/views/**/*' - - 'spec/acceptance/basic_dsc_resources/failing_dsc_resources_spec.rb' - - 'spec/acceptance/basic_functionality/puppet_apply_dsc_manifest_spec.rb' - - 'spec/acceptance/dsc_type/custom_resource_from_system_psmodulepath_spec.rb' - - 'spec/acceptance/dsc_type/custom_resource_path_spec.rb' - - 'spec/acceptance/dsc_type/multiple_dsc_resources_in_psmodulepath_spec.rb' - - 'spec/acceptance/reboot/negative/reboot_graph_cycle_spec.rb' - - 'spec/acceptance/reboot/reboot_autonotify_explicit_spec.rb' - - 'spec/acceptance/reboot/reboot_no_invoke_warning_spec.rb' - - 'spec/acceptance/unicode/puppet_apply_utf8_file_name_spec.rb' - - 'spec/unit/puppet/type/base_dsc_spec.rb' - - 'spec/unit/puppet/type/dsc_spec.rb' - -# Offense count: 14 -# Configuration parameters: CountAsOne. -RSpec/ExampleLength: - Max: 73 - -# Offense count: 1 -RSpec/LeakyConstantDeclaration: - Exclude: - - 'spec/acceptance/unicode/puppet_apply_utf8_file_name_spec.rb' - -# Offense count: 17 -RSpec/MultipleExpectations: - Max: 5 - -# Offense count: 1 -# Configuration parameters: AllowedPatterns. -# AllowedPatterns: ^expect_, ^assert_ -RSpec/NoExpectationExample: - Exclude: - - 'spec/unit/puppet/type/base_dsc_spec.rb' - -# Offense count: 3 -RSpec/PendingWithoutReason: - Exclude: - - 'spec/acceptance/reboot/negative/reboot_graph_cycle_spec.rb' - - 'spec/acceptance/reboot/reboot_autonotify_explicit_spec.rb' - - 'spec/acceptance/reboot/reboot_no_invoke_warning_spec.rb' - -# Offense count: 1 -RSpec/SkipBlockInsideExample: - Exclude: - - 'spec/acceptance/reboot/reboot_no_invoke_warning_spec.rb' - -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: MinBranchesCount. -Style/CaseLikeIf: - Exclude: - - 'spec/spec_helper_acceptance_local.rb' - -# Offense count: 2 -Style/MixinUsage: - Exclude: - - 'spec/spec_helper.rb' - - 'spec/spec_helper_acceptance.rb' - -# Offense count: 13 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: Mode. -Style/StringConcatenation: - Exclude: - - 'lib/puppet/provider/base_dsc_lite/powershell.rb' - 'lib/puppet/type/dsc.rb' - - 'lib/puppet_x/puppetlabs/dsc_lite/dsc_type_helpers.rb' - - 'lib/puppet_x/puppetlabs/dsc_lite/powershell_hash_formatter.rb' - - 'spec/acceptance/basic_functionality/puppet_apply_dsc_manifest_spec.rb' - -# Offense count: 3 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, AllowComments. -# AllowedMethods: define_method -Style/SymbolProc: - Exclude: - - 'lib/puppet_x/puppetlabs/dsc_lite/dsc_type_helpers.rb'