diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 48c14f7fb6..af25845765 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,3 +1,11 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2023-04-19 16:55:21 UTC using RuboCop version 1.48.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 +# versions of RuboCop, may require this file to be generated again. + # Offense count: 15 # This cop supports unsafe autocorrection (--autocorrect-all). Lint/BooleanSymbol: @@ -13,16 +21,22 @@ Lint/ConstantDefinitionInBlock: Exclude: - 'spec/unit/puppet/provider/postgresql_replication_slot/ruby_spec.rb' +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Lint/RedundantCopEnableDirective: + Exclude: + - 'spec/unit/puppet/type/postgresql_psql_spec.rb' + # Offense count: 6 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: - Max: 49 + Max: 48 -# Offense count: 8 +# Offense count: 7 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. # AllowedMethods: refine Metrics/BlockLength: - Max: 121 + Max: 119 # Offense count: 3 # Configuration parameters: AllowedMethods, AllowedPatterns. @@ -32,7 +46,7 @@ Metrics/CyclomaticComplexity: # Offense count: 6 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: - Max: 31 + Max: 29 # Offense count: 1 # Configuration parameters: CountKeywordArgs, MaxOptionalParameters. @@ -59,8 +73,7 @@ Naming/HeredocDelimiterNaming: - 'spec/defines/server/default_privileges_spec.rb' - 'spec/defines/server/grant_spec.rb' - -# Offense count: 104 +# Offense count: 101 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: @@ -76,7 +89,6 @@ RSpec/DescribeClass: RSpec/ExampleLength: Max: 53 - # Offense count: 3 RSpec/ExpectInHook: Exclude: @@ -96,10 +108,6 @@ RSpec/FilePath: - 'spec/defines/server/instance/service.rb' - 'spec/unit/puppet/type/postgresql_conn_validator.rb' - -RSpec/NamedSubject: - Enabled: false - # Offense count: 2 RSpec/LeakyConstantDeclaration: Exclude: @@ -119,6 +127,12 @@ RSpec/MultipleExpectations: RSpec/MultipleMemoizedHelpers: Max: 18 +# Offense count: 208 +# Configuration parameters: EnforcedStyle, IgnoreSharedExamples. +# SupportedStyles: always, named_only +RSpec/NamedSubject: + Enabled: false + # Offense count: 1 # Configuration parameters: AllowedGroups. RSpec/NestedGroups: @@ -160,6 +174,15 @@ Style/ClassAndModuleChildren: Exclude: - 'lib/puppet/util/postgresql_validator.rb' +# Offense count: 3 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Exclude: + - 'spec/**/*' + - 'lib/puppet/type/postgresql_psql.rb' + # Offense count: 2 # Configuration parameters: AllowedMethods. # AllowedMethods: respond_to_missing? diff --git a/lib/puppet/type/postgresql_psql.rb b/lib/puppet/type/postgresql_psql.rb index 2db3cd34b4..1fe67862e6 100644 --- a/lib/puppet/type/postgresql_psql.rb +++ b/lib/puppet/type/postgresql_psql.rb @@ -23,7 +23,7 @@ def retrieve def sync output, status = provider.run_sql_command(value) - raise("Error executing SQL; psql returned #{status}: '#{output}'") unless status.zero? + raise("Error executing SQL; psql returned #{status}: '#{output}'") unless status.to_i.zero? end end @@ -38,7 +38,7 @@ def sync # Return true if a matching row is found def matches(value) output, status = provider.run_unless_sql_command(value) - fail("Error evaluating 'unless' clause, returned #{status}: '#{output}'") unless status.zero? # rubocop:disable Style/SignalException + fail("Error evaluating 'unless' clause, returned #{status}: '#{output}'") unless status.to_i.zero? # rubocop:disable Style/SignalException result_count = output.strip.to_i debug("Found #{result_count} row(s) executing 'unless' clause") @@ -59,7 +59,7 @@ def matches(value) output, status = provider.run_unless_sql_command(value) status = output.exitcode if status.nil? - raise("Error evaluating 'onlyif' clause, returned #{status}: '#{output}'") unless status.zero? + raise("Error evaluating 'onlyif' clause, returned #{status}: '#{output}'") unless status.to_i.zero? result_count = output.strip.to_i debug("Found #{result_count} row(s) executing 'onlyif' clause")