From 3e68eef0284f8dd066d62c76096a3a4f816243cd Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 9 Jun 2024 14:47:35 +0200 Subject: [PATCH] Switch to voxpupuli-rubocop In the past puppetlabs_spec_helper pulls in an undefined version of RuboCop. RuboCop is known for introducing breaking changes in minor releases. voxupuli-rubocop provides a curated version of rubocop + dependencies + a RuboCop config based on community best practices. In addition dependabot is used to inform people about new voxpupuli-rubocop updates. This will ensure that puppetlabs_spec_helper won't randomly pull in new RuboCop versions that break CI again. --- .rubocop.yml | 16 +--- .rubocop_todo.yml | 159 +++++++++++++++++++++++---------- Gemfile | 5 -- puppetlabs_spec_helper.gemspec | 2 + 4 files changed, 118 insertions(+), 64 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 3e374020..c73c846a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,18 +1,8 @@ +--- inherit_from: .rubocop_todo.yml -require: - - rubocop-performance - - rubocop-rspec - -AllCops: - Exclude: - - Gemfile - - Rakefile - - spec/fixtures/**/* - - vendor/bundle/**/* - NewCops: enable - SuggestExtensions: false - TargetRubyVersion: '2.7' +inherit_gem: + voxpupuli-rubocop: rubocop.yml # Disabled Style/ClassAndModuleChildren: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ce9c1848..84be55c1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-02-09 08:47:26 UTC using RuboCop version 1.50.2. +# on 2024-06-09 12:47:09 UTC using RuboCop version 1.63.5. # 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 @@ -8,48 +8,30 @@ # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Severity, Include. -# Include: **/*.gemspec -Gemspec/RequireMFA: +# Configuration parameters: Width, AllowedPatterns. +Layout/IndentationWidth: Exclude: - - 'puppetlabs_spec_helper.gemspec' - -# Offense count: 5 -# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. -Metrics/AbcSize: - Max: 60 - -# Offense count: 3 -# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. -# AllowedMethods: refine -Metrics/BlockLength: - Max: 33 - -# Offense count: 4 -# Configuration parameters: AllowedMethods, AllowedPatterns. -Metrics/CyclomaticComplexity: - Max: 19 - -# Offense count: 11 -# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. -Metrics/MethodLength: - Max: 65 + - 'Rakefile' # Offense count: 1 -# Configuration parameters: CountComments, CountAsOne. -Metrics/ModuleLength: - Max: 277 +Lint/MixedRegexpCaptureTypes: + Exclude: + - 'Gemfile' -# Offense count: 3 -# Configuration parameters: CountKeywordArgs. -Metrics/ParameterLists: - MaxOptionalParameters: 4 - Max: 7 +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: strict, consistent +Lint/SymbolConversion: + Exclude: + - 'lib/puppetlabs_spec_helper/puppetlabs_spec/puppet_internals.rb' -# Offense count: 3 -# Configuration parameters: AllowedMethods, AllowedPatterns. -Metrics/PerceivedComplexity: - Max: 22 +# Offense count: 7 +# Configuration parameters: Prefixes, AllowedPatterns. +# Prefixes: when, with, without +RSpec/ContextWording: + Exclude: + - 'spec/unit/puppetlabs_spec_helper/tasks/fixtures_spec.rb' # Offense count: 1 # Configuration parameters: IgnoredMetadata. @@ -62,31 +44,55 @@ RSpec/DescribeClass: - '**/spec/views/**/*' - 'spec/acceptance/smoke_spec.rb' -# Offense count: 6 +# Offense count: 12 # Configuration parameters: CountAsOne. RSpec/ExampleLength: Max: 13 -# Offense count: 5 +# Offense count: 1 +# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. +# Include: **/*_spec*rb*, **/spec/**/* +RSpec/FilePath: + Exclude: + - 'spec/unit/puppetlabs_spec_helper/tasks/fixtures_spec.rb' + +# Offense count: 8 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: implicit, each, example +RSpec/HookArgument: + Exclude: + - 'spec/unit/puppetlabs_spec_helper/tasks/fixtures_spec.rb' + +# Offense count: 7 # Configuration parameters: . # SupportedStyles: have_received, receive RSpec/MessageSpies: EnforcedStyle: receive -# Offense count: 5 +# Offense count: 8 RSpec/MultipleExpectations: Max: 3 -# Offense count: 7 +# Offense count: 14 # Configuration parameters: AllowedGroups. RSpec/NestedGroups: Max: 5 -# Offense count: 5 +# Offense count: 1 +# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. +# Include: **/*_spec.rb +RSpec/SpecFilePathFormat: + Exclude: + - '**/spec/routing/**/*' + - 'spec/unit/puppetlabs_spec_helper/tasks/fixtures_spec.rb' + +# Offense count: 7 RSpec/StubbedMock: Exclude: - 'spec/unit/puppetlabs_spec_helper/puppetlabs_spec/puppet_internals_spec.rb' - 'spec/unit/puppetlabs_spec_helper/tasks/fixture_helpers_spec.rb' + - 'spec/unit/puppetlabs_spec_helper/tasks/fixtures_spec.rb' # Offense count: 2 Security/Eval: @@ -94,10 +100,18 @@ Security/Eval: - 'lib/puppetlabs_spec_helper/tasks/fixtures.rb' # Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). Style/CombinableLoops: Exclude: - 'lib/puppetlabs_spec_helper/tasks/fixtures.rb' +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowedVars. +Style/FetchEnvVar: + Exclude: + - 'Gemfile' + # Offense count: 7 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns. @@ -111,16 +125,69 @@ Style/GlobalVars: Exclude: - 'lib/puppetlabs_spec_helper/puppetlabs_spec/files.rb' +# Offense count: 4 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. +# AllowedReceivers: Thread.current +Style/HashEachMethods: + Exclude: + - 'lib/puppetlabs_spec_helper/tasks/fixtures.rb' + # Offense count: 1 Style/MixinUsage: Exclude: - 'lib/puppetlabs_spec_helper/tasks/fixtures.rb' -# Offense count: 9 +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantRegexpEscape: + Exclude: + - 'Gemfile' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, AllowInnerSlashes. +# SupportedStyles: slashes, percent_r, mixed +Style/RegexpLiteral: + Exclude: + - 'Gemfile' + - 'spec/unit/puppetlabs_spec_helper/tasks/fixtures_spec.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Exclude: + - 'Rakefile' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, AllowSafeAssignment. +# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex +Style/TernaryParentheses: + Exclude: + - 'lib/puppetlabs_spec_helper/tasks/fixtures.rb' + - 'spec/watchr.rb' + +# Offense count: 12 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, no_comma -Style/TrailingCommaInArguments: +Style/TrailingCommaInArrayLiteral: Exclude: - - 'lib/puppetlabs_spec_helper/tasks/fixtures.rb' + - 'lib/puppetlabs_spec_helper/module_spec_helper.rb' + - 'lib/puppetlabs_spec_helper/tasks/check_symlinks.rb' + - 'spec/spec_helper.rb' + - 'spec/unit/puppetlabs_spec_helper/tasks/check_symlinks_spec.rb' + - 'spec/unit/puppetlabs_spec_helper/tasks/check_test_file_spec.rb' + +# Offense count: 26 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInHashLiteral: + Exclude: + - 'lib/puppetlabs_spec_helper/rake_tasks.rb' + - 'spec/unit/puppetlabs_spec_helper/tasks/check_symlinks_spec.rb' - 'spec/unit/puppetlabs_spec_helper/tasks/fixture_helpers_spec.rb' diff --git a/Gemfile b/Gemfile index 6660ec71..b0f2d981 100644 --- a/Gemfile +++ b/Gemfile @@ -30,11 +30,6 @@ group :development do gem 'rake' gem 'rspec', '~> 3.1' gem 'rspec-its', '~> 1.0' - gem 'rubocop', '~> 1.50.0', require: false - gem 'rubocop-rspec', '~> 2.19', require: false - gem 'rubocop-performance', '~> 1.16', require: false - gem 'rubocop-factory_bot', '!= 2.26.0', require: false - gem 'rubocop-rspec_rails', '!= 2.29.0', require: false gem 'fakefs' gem 'yard' diff --git a/puppetlabs_spec_helper.gemspec b/puppetlabs_spec_helper.gemspec index 64e0e1d6..1d801adc 100644 --- a/puppetlabs_spec_helper.gemspec +++ b/puppetlabs_spec_helper.gemspec @@ -35,5 +35,7 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency 'rspec-github', '~> 2.0' spec.add_runtime_dependency 'rspec-puppet', '~> 4.0' + spec.add_development_dependency 'voxpupuli-rubocop', '~> 2.7.0' + spec.requirements << 'puppet, >= 7.0.0' end