From 25de071268864b49e845ce0317631e733c14746c Mon Sep 17 00:00:00 2001 From: Alexander Fisher Date: Sat, 13 Mar 2021 17:13:13 +0000 Subject: [PATCH] Use latest rubocop and target ruby 2.4 --- rubocop.yml | 137 ++++++++++++++++++++++++++++------------- voxpupuli-test.gemspec | 7 ++- 2 files changed, 100 insertions(+), 44 deletions(-) diff --git a/rubocop.yml b/rubocop.yml index f438c09..e71222d 100644 --- a/rubocop.yml +++ b/rubocop.yml @@ -3,10 +3,12 @@ require: rubocop-rspec AllCops: -# Puppet Server 5 defaults to jruby 1.7 so TargetRubyVersion must stay at 1.9 until we drop support for puppet 5 - TargetRubyVersion: 1.9 + # Ruby 2.4 is the oldest version we can use with the latest version of rubocop (1.11.0 as of 13/03/2021). + # Puppet agent 5 ships with ruby 2.4. Puppetserver 5 has JRuby 2.1.x which is only ruby 2.3 compatible, but this + # is unlikely to cause many issues. If/when it does, we can disable the relevant cop inline as appropriate. + TargetRubyVersion: 2.4 Include: - - ./**/*.rb + - '**/*.rb' Exclude: - files/**/* - vendor/**/* @@ -18,7 +20,7 @@ AllCops: - Guardfile - Vagrantfile -Lint/ConditionPosition: +Layout/ConditionPosition: Enabled: True Lint/ElseLayout: @@ -27,16 +29,16 @@ Lint/ElseLayout: Lint/UnreachableCode: Enabled: True -Lint/UselessComparison: +Lint/BinaryOperatorWithIdenticalOperands: Enabled: True Lint/EnsureReturn: Enabled: True -Lint/HandleExceptions: +Lint/SuppressedException: Enabled: True -Lint/LiteralInCondition: +Lint/LiteralAsCondition: Enabled: True Lint/ShadowingOuterLocalVariable: @@ -89,13 +91,13 @@ Lint/AmbiguousRegexpLiteral: Security/Eval: Enabled: True -Lint/BlockAlignment: +Layout/BlockAlignment: Enabled: True -Lint/DefEndAlignment: +Layout/DefEndAlignment: Enabled: True -Lint/EndAlignment: +Layout/EndAlignment: Enabled: True Lint/DeprecatedClassMethods: @@ -110,7 +112,7 @@ Lint/ParenthesesAsGroupedExpression: Lint/RescueException: Enabled: True -Lint/StringConversionInInterpolation: +Lint/RedundantStringCoercion: Enabled: True Lint/UnusedBlockArgument: @@ -122,28 +124,25 @@ Lint/UnusedMethodArgument: Lint/UselessAccessModifier: Enabled: True -Lint/UselessAssignment: - Enabled: True - Lint/Void: Enabled: True Layout/AccessModifierIndentation: Enabled: True -Style/AccessorMethodName: +Naming/AccessorMethodName: Enabled: True Style/Alias: Enabled: True -Layout/AlignArray: +Layout/ArrayAlignment: Enabled: True -Layout/AlignHash: +Layout/HashAlignment: Enabled: True -Layout/AlignParameters: +Layout/ParameterAlignment: Enabled: True Metrics/BlockNesting: @@ -155,22 +154,16 @@ Style/AsciiComments: Style/Attr: Enabled: True -Style/BracesAroundHashParameters: - Enabled: False - Style/CaseEquality: Enabled: True -Style/TrailingCommaInArguments: - Enabled: False - Layout/CaseIndentation: Enabled: True Style/CharacterLiteral: Enabled: True -Style/ClassAndModuleCamelCase: +Naming/ClassAndModuleCamelCase: Enabled: True Style/ClassAndModuleChildren: @@ -195,22 +188,22 @@ Style/WhenThen: Style/WordArray: Enabled: True -Style/UnneededPercentQ: +Style/RedundantPercentQ: Enabled: True -Layout/Tab: +Layout/IndentationStyle: Enabled: True Layout/SpaceBeforeSemicolon: Enabled: True -Layout/TrailingBlankLines: +Layout/TrailingEmptyLines: Enabled: True Layout/SpaceInsideBlockBraces: Enabled: True -Layout/SpaceInsideBrackets: +Layout/SpaceBeforeBrackets: Enabled: True Layout/SpaceInsideHashLiteralBraces: @@ -268,7 +261,7 @@ Style/CommentAnnotation: Metrics/CyclomaticComplexity: Enabled: False -Style/ConstantName: +Naming/ConstantName: Enabled: True Style/Documentation: @@ -292,10 +285,10 @@ Style/EachWithObject: Layout/EmptyLineBetweenDefs: Enabled: True -Layout/IndentArray: +Layout/FirstArrayElementIndentation: Enabled: True -Layout/IndentHash: +Layout/FirstHashElementIndentation: Enabled: True Layout/IndentationConsistency: @@ -314,7 +307,7 @@ Style/EmptyLiteral: Enabled: True # Configuration parameters: AllowURI, URISchemes. -Metrics/LineLength: +Layout/LineLength: Enabled: False Style/MethodCallWithoutArgsParentheses: @@ -335,7 +328,10 @@ Style/StringLiterals: Style/TrailingCommaInArguments: Enabled: True -Style/TrailingCommaInLiteral: +Style/TrailingCommaInArrayLiteral: + Enabled: False + +Style/TrailingCommaInHashLiteral: Enabled: False Style/GlobalVars: @@ -377,7 +373,7 @@ Style/UnlessElse: Style/VariableInterpolation: Enabled: True -Style/VariableName: +Naming/VariableName: Enabled: True Style/WhileUntilDo: @@ -386,7 +382,7 @@ Style/WhileUntilDo: Style/EvenOdd: Enabled: True -Style/FileName: +Naming/FileName: Enabled: True Style/For: @@ -395,7 +391,7 @@ Style/For: Style/Lambda: Enabled: True -Style/MethodName: +Naming/MethodName: Enabled: True Style/MultilineTernaryOperator: @@ -431,7 +427,7 @@ Style/NumericLiterals: Style/OneLineConditional: Enabled: True -Style/OpMethod: +Naming/BinaryOperatorParameterName: Enabled: True Style/ParenthesesAroundCondition: @@ -443,7 +439,7 @@ Style/PercentLiteralDelimiters: Style/PerlBackrefs: Enabled: True -Style/PredicateName: +Naming/PredicateName: Enabled: True Style/RedundantException: @@ -538,9 +534,8 @@ RSpec/NestedGroups: RSpec/MultipleExpectations: Enabled: false -# this is broken on ruby1.9 -Layout/IndentHeredoc: - Enabled: False +Layout/HeredocIndentation: + Enabled: True Security/YAMLLoad: Enabled: True @@ -553,3 +548,61 @@ Style/FormatStringToken: # are located. RSpec/FilePath: Enabled: false + +# New cops available after rubocop upgrade +Gemspec/DateAssignment: # (new in 1.10) + Enabled: true +Lint/AmbiguousAssignment: # (new in 1.7) + Enabled: true +Lint/DeprecatedConstants: # (new in 1.8) + Enabled: true +Lint/DuplicateBranch: # (new in 1.3) + Enabled: true +Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1) + Enabled: true +Lint/EmptyBlock: # (new in 1.1) + Enabled: true +Lint/EmptyClass: # (new in 1.3) + Enabled: true +Lint/LambdaWithoutLiteralBlock: # (new in 1.8) + Enabled: true +Lint/NoReturnInBeginEndBlocks: # (new in 1.2) + Enabled: true +Lint/NumberedParameterAssignment: # (new in 1.9) + Enabled: true +Lint/OrAssignmentToConstant: # (new in 1.9) + Enabled: true +Lint/RedundantDirGlobSort: # (new in 1.8) + Enabled: true +Lint/SymbolConversion: # (new in 1.9) + Enabled: true +Lint/ToEnumArguments: # (new in 1.1) + Enabled: true +Lint/TripleQuotes: # (new in 1.9) + Enabled: true +Lint/UnexpectedBlockArity: # (new in 1.5) + Enabled: true +Lint/UnmodifiedReduceAccumulator: # (new in 1.1) + Enabled: true +Style/ArgumentsForwarding: # (new in 1.1) + Enabled: true +Style/CollectionCompact: # (new in 1.2) + Enabled: true +Style/DocumentDynamicEvalDefinition: # (new in 1.1) + Enabled: true +Style/EndlessMethod: # (new in 1.8) + Enabled: true +Style/HashConversion: # (new in 1.10) + Enabled: true +Style/HashExcept: # (new in 1.7) + Enabled: true +Style/IfWithBooleanLiteralBranches: # (new in 1.9) + Enabled: true +Style/NegatedIfElseCondition: # (new in 1.2) + Enabled: true +Style/NilLambda: # (new in 1.3) + Enabled: true +Style/RedundantArgument: # (new in 1.4) + Enabled: true +Style/SwapValues: # (new in 1.1) + Enabled: true diff --git a/voxpupuli-test.gemspec b/voxpupuli-test.gemspec index f398cc8..d7ecacd 100644 --- a/voxpupuli-test.gemspec +++ b/voxpupuli-test.gemspec @@ -12,6 +12,8 @@ Gem::Specification.new do |s| s.files = Dir['lib/**/*.rb', 'rubocop.yml'] + s.required_ruby_version = '>= 2.4.0' + s.add_runtime_dependency 'rake' # Testing @@ -23,8 +25,9 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'rspec-puppet-utils', '>= 1.9.5' # Rubocop - s.add_runtime_dependency 'rubocop', '~> 0.49.1' - s.add_runtime_dependency 'rubocop-rspec', '~> 1.16.0' + s.add_runtime_dependency 'rubocop', '~> 1.11.0' + s.add_runtime_dependency 'rubocop-rspec', '~> 2.2.0' + s.add_runtime_dependency 'rubocop-rake', '~> 0.5.1' # Linting s.add_runtime_dependency 'puppet-lint-absolute_classname-check', '>= 2.0.0'