diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4a22c2fea..84f3535cb 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-auto-gen-timestamp` -# using RuboCop version 1.81.1. +# using RuboCop version 1.85.1. # 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,7 +8,7 @@ # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleAlignWith, Severity. +# Configuration parameters: EnforcedStyleAlignWith. # SupportedStylesAlignWith: start_of_line, begin Layout/BeginEndAlignment: Exclude: @@ -29,7 +29,7 @@ Layout/ClosingHeredocIndentation: - 'spec/unit/pal_spec.rb' - 'spec/unit/util/format_spec.rb' -# Offense count: 656 +# Offense count: 660 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. # SupportedHashRocketStyles: key, separator, table @@ -38,12 +38,12 @@ Layout/ClosingHeredocIndentation: Layout/HashAlignment: Enabled: false -# Offense count: 53 +# Offense count: 52 # This cop supports safe autocorrection (--autocorrect). Layout/HeredocIndentation: Enabled: false -# Offense count: 24 +# Offense count: 25 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: aligned, indented @@ -127,6 +127,7 @@ Lint/UselessConstantScoping: - 'lib/bolt/transport/winrm/connection.rb' # Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). Lint/UselessOr: Exclude: - 'spec/integration/transport/winrm_spec.rb' @@ -144,7 +145,7 @@ Naming/BlockForwarding: # Offense count: 16 # Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates. # AllowedMethods: call -# WaywardPredicates: nonzero? +# WaywardPredicates: infinite?, nonzero? Naming/PredicateMethod: Exclude: - 'bolt-modules/file/lib/puppet/functions/file/exists.rb' @@ -256,7 +257,7 @@ Performance/RedundantStringChars: Exclude: - 'lib/bolt/config/transport/base.rb' -# Offense count: 36 +# Offense count: 40 # This cop supports safe autocorrection (--autocorrect). Performance/RegexpMatch: Enabled: false @@ -267,7 +268,7 @@ Performance/Size: Exclude: - 'lib/bolt/validator.rb' -# Offense count: 20 +# Offense count: 22 # This cop supports unsafe autocorrection (--autocorrect-all). Performance/StringInclude: Enabled: false @@ -285,18 +286,16 @@ Performance/Sum: Exclude: - 'lib/bolt/executor.rb' -# Offense count: 13 +# Offense count: 10 # This cop supports unsafe autocorrection (--autocorrect-all). Performance/UnfreezeString: Exclude: - - 'lib/bolt/cli.rb' - 'lib/bolt/module_installer/specs.rb' - 'lib/bolt/outputter/rainbow.rb' - 'lib/bolt/pal/yaml_plan/parameter.rb' - 'lib/bolt/pal/yaml_plan/step.rb' - 'lib/bolt/pal/yaml_plan/step/eval.rb' - 'lib/bolt/pal/yaml_plan/transpiler.rb' - - 'lib/bolt/plugin/puppetdb.rb' - 'lib/bolt/shell/bash.rb' - 'lib/bolt/util.rb' @@ -320,7 +319,7 @@ RSpec/BeEmpty: Exclude: - 'spec/unit/project_manager/module_migrator_spec.rb' -# Offense count: 93 +# Offense count: 92 # This cop supports unsafe autocorrection (--autocorrect-all). RSpec/BeEq: Enabled: false @@ -367,18 +366,18 @@ RSpec/ClassCheck: Exclude: - 'spec/integration/puppetdb/puppetdb_spec.rb' -# Offense count: 70 +# Offense count: 71 # This cop supports safe autocorrection (--autocorrect). RSpec/ContextMethod: Enabled: false -# Offense count: 331 +# Offense count: 332 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: Enabled: false -# Offense count: 109 +# Offense count: 110 # Configuration parameters: IgnoredMetadata. RSpec/DescribeClass: Enabled: false @@ -395,26 +394,26 @@ RSpec/DescribeSymbol: - 'spec/unit/plugin/module_spec.rb' - 'spec/unit/result_spec.rb' -# Offense count: 268 +# Offense count: 266 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants. # SupportedStyles: described_class, explicit RSpec/DescribedClass: Enabled: false -# Offense count: 656 +# Offense count: 653 # Configuration parameters: CountAsOne. RSpec/ExampleLength: Max: 42 -# Offense count: 177 +# Offense count: 180 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples. # DisallowedExamples: works RSpec/ExampleWording: Enabled: false -# Offense count: 32 +# Offense count: 31 RSpec/ExpectInHook: Exclude: - 'spec/bolt_spec/run_spec.rb' @@ -457,7 +456,7 @@ RSpec/IndexedLet: - 'spec/unit/result_set_spec.rb' - 'spec/unit/util/format_spec.rb' -# Offense count: 255 +# Offense count: 259 # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: Enabled: false @@ -490,7 +489,7 @@ RSpec/MatchArray: - 'spec/unit/target_spec.rb' - 'spec/unit/transport/ssh/connection_spec.rb' -# Offense count: 336 +# Offense count: 332 # Configuration parameters: . # SupportedStyles: have_received, receive RSpec/MessageSpies: @@ -516,7 +515,7 @@ RSpec/MultipleDescribes: RSpec/MultipleMemoizedHelpers: Max: 27 -# Offense count: 143 +# Offense count: 137 # Configuration parameters: EnforcedStyle, IgnoreSharedExamples. # SupportedStyles: always, named_only RSpec/NamedSubject: @@ -556,6 +555,14 @@ RSpec/NotToNot: - 'spec/unit/applicator_spec.rb' - 'spec/unit/plugin/puppet_library_spec.rb' +# Offense count: 3 +# This cop supports unsafe autocorrection (--autocorrect-all). +RSpec/Output: + Exclude: + - 'bolt-modules/boltlib/spec/fixtures/modules/test/tasks/references.rb' + - 'bolt-modules/boltlib/spec/functions/catch_errors_spec.rb' + - 'spec/integration/apply_spec.rb' + # Offense count: 29 # This cop supports unsafe autocorrection (--autocorrect-all). RSpec/ReceiveMessages: @@ -629,7 +636,8 @@ RSpec/SortMetadata: - 'spec/integration/inventory_spec.rb' # Offense count: 78 -# Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata. +# Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata, InflectorPath, EnforcedInflector. +# SupportedInflectors: default, active_support RSpec/SpecFilePathFormat: Enabled: false @@ -640,11 +648,11 @@ RSpec/SpecFilePathSuffix: - 'bolt-modules/boltlib/spec/functions/puppetdb_query.rb' - 'spec/integration/task_param.rb' -# Offense count: 104 +# Offense count: 103 RSpec/StubbedMock: Enabled: false -# Offense count: 3 +# Offense count: 2 RSpec/SubjectDeclaration: Exclude: - 'spec/unit/transport/ssh/connection_spec.rb' @@ -672,7 +680,7 @@ RSpec/VerifiedDoubleReference: - 'spec/unit/applicator_spec.rb' - 'spec/unit/inventory/group_spec.rb' -# Offense count: 109 +# Offense count: 108 # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. RSpec/VerifiedDoubles: Enabled: false @@ -719,7 +727,7 @@ Style/ArrayIntersect: Exclude: - 'bolt-modules/boltlib/lib/puppet/functions/download_file.rb' -# Offense count: 242 +# Offense count: 238 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces @@ -768,24 +776,6 @@ Style/ExplicitBlockArgument: - 'lib/bolt/result_set.rb' - 'spec/lib/bolt_spec/errors.rb' -# Offense count: 16 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowedVars, DefaultToNil. -Style/FetchEnvVar: - Exclude: - - 'acceptance/Rakefile' - - 'acceptance/setup/package/pre-suite/020_install.rb' - - 'bolt-modules/system/lib/puppet/functions/system/env.rb' - - 'bolt-modules/system/spec/functions/system/env_spec.rb' - - 'developer-docs/examples/bolt_spec_example/tasks/init.rb' - - 'lib/bolt/applicator.rb' - - 'lib/bolt/config.rb' - - 'lib/bolt/plugin/env_var.rb' - - 'lib/bolt/puppetdb/config.rb' - - 'scripts/generate_changelog.rb' - - 'spec/integration/local_spec.rb' - - 'spec/lib/bolt_spec/env_var.rb' - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Style/FileEmpty: @@ -798,6 +788,11 @@ Style/FileNull: Exclude: - 'lib/bolt/puppetdb/config.rb' +# Offense count: 2 +Style/FileOpen: + Exclude: + - 'dev-resources/bump_mods.rb' + # Offense count: 4 # This cop supports safe autocorrection (--autocorrect). Style/FileRead: @@ -822,7 +817,7 @@ Style/FrozenStringLiteralComment: - '**/*.arb' - 'scripts/check_dependencies.rb' -# Offense count: 97 +# Offense count: 95 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. Style/GuardClause: @@ -868,13 +863,7 @@ Style/HashExcept: - 'lib/bolt/plugin/cache.rb' - 'lib/bolt/result.rb' -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/HashTransformValues: - Exclude: - - 'scripts/check_dependencies.rb' - -# Offense count: 160 +# Offense count: 213 # This cop supports safe autocorrection (--autocorrect). Style/IfUnlessModifier: Enabled: false @@ -929,6 +918,12 @@ Style/NumericPredicate: - 'lib/bolt_spec/plans/action_stubs.rb' - 'libexec/apply_catalog.rb' +# Offense count: 1 +# Configuration parameters: AllowedClasses. +Style/OneClassPerFile: + Exclude: + - 'scripts/check_dependencies.rb' + # Offense count: 19 # Configuration parameters: AllowedMethods. # AllowedMethods: respond_to_missing? @@ -943,6 +938,20 @@ Style/QuotedSymbols: Exclude: - 'spec/integration/transport/winrm_spec.rb' +# Offense count: 13 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/ReduceToHash: + Exclude: + - 'bolt-modules/boltlib/lib/puppet/functions/run_plan.rb' + - 'lib/bolt/apply_result.rb' + - 'lib/bolt/executor.rb' + - 'lib/bolt/pal.rb' + - 'lib/bolt/puppetdb/client.rb' + - 'lib/bolt/result_set.rb' + - 'lib/bolt/task.rb' + - 'rakelib/schemas.rake' + - 'spec/unit/executor_spec.rb' + # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Style/RedundantConstantBase: @@ -1020,6 +1029,15 @@ Style/SafeNavigation: - 'lib/bolt_spec/plans/mock_executor.rb' - 'rakelib/pwsh.rake' +# Offense count: 4 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/SelectByKind: + Exclude: + - 'bolt-modules/boltlib/lib/puppet/functions/run_command.rb' + - 'bolt-modules/boltlib/lib/puppet/functions/run_container.rb' + - 'bolt-modules/boltlib/lib/puppet/functions/run_script.rb' + - 'lib/bolt/catalog.rb' + # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Style/SelectByRegexp: @@ -1074,13 +1092,13 @@ Style/StderrPuts: - 'lib/bolt_spec/plans/action_stubs.rb' - 'libexec/apply_catalog.rb' -# Offense count: 157 +# Offense count: 154 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Mode. Style/StringConcatenation: Enabled: false -# Offense count: 3277 +# Offense count: 3351 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes @@ -1096,29 +1114,21 @@ Style/SuperArguments: - 'lib/bolt/error.rb' - 'lib/bolt_spec/plans/action_stubs/plan_stub.rb' -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, AllowComments. -# AllowedMethods: define_method -Style/SymbolProc: - Exclude: - - 'scripts/check_dependencies.rb' - -# Offense count: 29 +# Offense count: 31 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, AllowSafeAssignment. # SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex Style/TernaryParentheses: Enabled: false -# Offense count: 522 +# Offense count: 521 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma Style/TrailingCommaInArguments: Enabled: false -# Offense count: 225 +# Offense count: 227 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma @@ -1137,10 +1147,3 @@ Style/TrailingCommaInHashLiteral: Style/YAMLFileRead: Exclude: - 'spec/unit/module_installer_spec.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings. -# URISchemes: http, https -Layout/LineLength: - Max: 121 diff --git a/lib/bolt/pal/yaml_plan/transpiler.rb b/lib/bolt/pal/yaml_plan/transpiler.rb index 414d1aaf0..a4c5e17ce 100644 --- a/lib/bolt/pal/yaml_plan/transpiler.rb +++ b/lib/bolt/pal/yaml_plan/transpiler.rb @@ -22,7 +22,7 @@ def transpile(plan_path) plan_object = parse_plan param_descriptions = plan_object.parameters.map do |param| - str = String.new("# @param #{param.name}") + str = "# @param #{param.name}" str << " #{param.description}" if param.description str end.join("\n") diff --git a/lib/bolt/plugin/puppetdb.rb b/lib/bolt/plugin/puppetdb.rb index 6e1ba7788..3eb40f63d 100644 --- a/lib/bolt/plugin/puppetdb.rb +++ b/lib/bolt/plugin/puppetdb.rb @@ -5,7 +5,7 @@ class Plugin class Puppetdb class FactLookupError < Bolt::Error def initialize(fact, err = nil) - m = String.new("Fact lookup '#{fact}' contains an invalid factname") + m = "Fact lookup '#{fact}' contains an invalid factname" m << ": #{err}" unless err.nil? super(m, 'bolt.plugin/fact-lookup-error') end diff --git a/lib/bolt/result_set.rb b/lib/bolt/result_set.rb index a6f8e604c..4e4a01d27 100644 --- a/lib/bolt/result_set.rb +++ b/lib/bolt/result_set.rb @@ -27,7 +27,7 @@ def _pcore_init_hash def iterator if Object.const_defined?(:Puppet) && Puppet.const_defined?(:Pops) && - self.class.included_modules.include?(Puppet::Pops::Types::Iterable) + self.class.include?(Puppet::Pops::Types::Iterable) Puppet::Pops::Types::Iterable.on(@results, Bolt::Result) else raise NotImplementedError, "iterator requires puppet code to be loaded." diff --git a/openbolt.gemspec b/openbolt.gemspec index 7ebe3eb26..33fc07e7a 100644 --- a/openbolt.gemspec +++ b/openbolt.gemspec @@ -70,5 +70,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency "octokit", ">= 4.0", "< 9" spec.add_development_dependency "rake", ">= 12.0", "< 14" spec.add_development_dependency "rspec", ">= 3.0", "< 4" - spec.add_development_dependency 'voxpupuli-rubocop', '~> 5.0.0' + spec.add_development_dependency 'voxpupuli-rubocop', '~> 5.2.0' end diff --git a/spec/unit/pal/yaml_plan_spec.rb b/spec/unit/pal/yaml_plan_spec.rb index 21ac8f497..d3da023be 100644 --- a/spec/unit/pal/yaml_plan_spec.rb +++ b/spec/unit/pal/yaml_plan_spec.rb @@ -336,7 +336,7 @@ it "evaluates nested variable lookups" do str = described_class.new("$foo[0][$bar]") - scope.with_local_scope('foo' => ['testkey' => 'hello world'], 'bar' => 'testkey') do |local_scope| + scope.with_local_scope('foo' => [{ 'testkey' => 'hello world' }], 'bar' => 'testkey') do |local_scope| expect(str.evaluate(local_scope, evaluator)).to eq("hello world") end end