From d4a159571025aba66994a1ca27b96446ec379517 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 5 Sep 2024 22:02:46 +0200 Subject: [PATCH] rubocop: autofix --- .rubocop_todo.yml | 49 ++++++++++--------- lib/docs/generate.rb | 2 +- .../custom_facts/core/execution/base.rb | 3 +- lib/facter/framework/cli/cli.rb | 2 +- 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 11e618abb2..b8fce1d19e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-01-08 20:12:30 UTC using RuboCop version 1.59.0. +# on 2024-09-05 20:01:51 UTC using RuboCop version 1.64.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 @@ -18,35 +18,40 @@ Performance/RegexpMatch: RSpec/FilePath: Enabled: false -# Need to remove logger class variables +# Offense count: 14 Style/ClassVars: Exclude: - 'lib/facter/framework/logging/logger.rb' - 'spec/custom_facts/puppetlabs_spec/files.rb' - - 'spec/facter/util/file_helper_spec.rb' - - 'spec/framework/core/fact/internal/internal_fact_manager_spec.rb' - 'spec/framework/logging/logger_spec.rb' +# Offense count: 977 +# Configuration parameters: AllowedConstants. Style/Documentation: + Enabled: false + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/IdenticalConditionalBranches: Exclude: - - 'lib/facter.rb' # should be documented - - 'lib/facter/config.rb' # should be documented - - 'lib/facter/custom_facts/**/*' # should be documented - - 'lib/facter/facts/**/*' # don't care - - 'lib/facter/framework/**/*' # should be documented - - 'lib/facter/models/**/*' # should be documented - - 'lib/facter/resolvers/**/*' # don't care - - 'lib/facter/util/**/*' - - 'lib/facter/version.rb' # auto updated - - 'spec/**/*' - - 'spec_integration/**/*' - - 'scripts/*' - - 'install.rb' + - 'lib/docs/generate.rb' -# While it would be preferable to use a keyword argument for the proxy setting in #get_request and #put_request, if we -# add keyword arguments to those methods Ruby < 3 misinterprets earlier positional arguments as a keyword arguments. -# This is because those positional arguments are hashes that use symbols as keys. -# TODO: revisit this after we drop Ruby < 3 support. +# Offense count: 2 +# Configuration parameters: AllowedMethods. +# AllowedMethods: respond_to_missing? Style/OptionalBooleanParameter: Exclude: - - 'lib/facter/util/resolvers/http.rb' \ No newline at end of file + - 'lib/facter/util/resolvers/http.rb' + +# Offense count: 13 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/SlicingWithRange: + Exclude: + - 'install.rb' + - 'lib/facter/facts/solaris/ldom.rb' + - 'lib/facter/framework/cli/cli.rb' + - 'lib/facter/resolvers/aix/serialnumber.rb' + - 'lib/facter/resolvers/freebsd/swap_memory.rb' + - 'lib/facter/resolvers/networking.rb' + - 'lib/facter/resolvers/partitions.rb' + - 'lib/facter/util/api_debugger.rb' diff --git a/lib/docs/generate.rb b/lib/docs/generate.rb index 9ed92a0112..73d2011b8c 100755 --- a/lib/docs/generate.rb +++ b/lib/docs/generate.rb @@ -21,7 +21,7 @@ def format_facts(fact_hash) erb = if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+ ERB.new(File.read(PATH_TO_TEMPLATE), trim_mode: '-') else - ERB.new(File.read(PATH_TO_TEMPLATE), nil, '-') + ERB.new(File.read(PATH_TO_TEMPLATE), trim_mode: '-') end erb.result(scope.instance_eval { binding }) end diff --git a/lib/facter/custom_facts/core/execution/base.rb b/lib/facter/custom_facts/core/execution/base.rb index 6d4a5d8cf9..af390c1d6a 100644 --- a/lib/facter/custom_facts/core/execution/base.rb +++ b/lib/facter/custom_facts/core/execution/base.rb @@ -26,7 +26,7 @@ def with_env(values) ENV[var] = value end # execute the caller's block, capture the return value - rv = yield + yield # use an ensure block to make absolutely sure we restore the variables ensure # restore the old values @@ -39,7 +39,6 @@ def with_env(values) end end # return the captured return value - rv end def execute(command, options = {}) diff --git a/lib/facter/framework/cli/cli.rb b/lib/facter/framework/cli/cli.rb index 55d9c13c19..7f430f91f0 100755 --- a/lib/facter/framework/cli/cli.rb +++ b/lib/facter/framework/cli/cli.rb @@ -113,7 +113,7 @@ def man(*args) negate_options = %w[block cache custom_facts external_facts] template = File.join(File.dirname(__FILE__), '..', '..', 'templates', 'man.erb') - erb = ERB.new(File.read(template), nil, '-') + erb = ERB.new(File.read(template), trim_mode: '-') erb.filename = template puts erb.result(binding) end