diff --git a/.rubocop.yml b/.rubocop.yml index c773d1b6..c3409f41 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,7 +1,12 @@ --- -require: -- rubocop-performance -- rubocop-rspec +inherit_from: .rubocop_todo.yml + +plugins: + - rubocop-rspec + - rubocop-rspec_rails + - rubocop-performance + - rubocop-factory_bot + - rubocop-capybara AllCops: NewCops: enable DisplayCopNames: true @@ -294,7 +299,7 @@ Performance/UriDefaultParser: Enabled: false RSpec/Be: Enabled: false -RSpec/Capybara/FeatureMethods: +RSpec/Dialect: Enabled: false RSpec/ContainExactly: Enabled: false @@ -320,11 +325,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 +605,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 +617,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/.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' 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 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'