From ff701bc72ab5d67026d80b7ce2e23d620d64561d Mon Sep 17 00:00:00 2001 From: Lukas Audzevicius Date: Tue, 19 Dec 2023 10:56:47 +0000 Subject: [PATCH] (CAT-1653) Fix Rubocop issues Prior to this commit, on an unexpected rubocop update, some of our repositories started highlighting errors for new rubocop rules. This has caused our CI to fail. This commit aims to address these failures. --- lib/puppet-lint.rb | 2 +- lib/puppet-lint/checks.rb | 2 +- lib/puppet-lint/configuration.rb | 8 ++++---- lib/puppet-lint/optparser.rb | 10 +++++----- lib/puppet-lint/tasks/puppet-lint.rb | 8 ++++---- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/puppet-lint.rb b/lib/puppet-lint.rb index 580dbd60..06af3af3 100644 --- a/lib/puppet-lint.rb +++ b/lib/puppet-lint.rb @@ -252,7 +252,7 @@ def print_problems # end def self.new_check(name, &block) class_name = name.to_s.split('_').map(&:capitalize).join - klass = PuppetLint.const_set("Check#{class_name}", Class.new(PuppetLint::CheckPlugin)) + klass = PuppetLint.const_set(:"Check#{class_name}", Class.new(PuppetLint::CheckPlugin)) klass.const_set(:NAME, name) klass.class_exec(&block) PuppetLint.configuration.add_check(name, klass) diff --git a/lib/puppet-lint/checks.rb b/lib/puppet-lint/checks.rb index 399508f5..6b3989f3 100644 --- a/lib/puppet-lint/checks.rb +++ b/lib/puppet-lint/checks.rb @@ -121,7 +121,7 @@ def run(fileinfo, data) # Returns an Array of String check names. def enabled_checks @enabled_checks ||= PuppetLint.configuration.checks.select do |check| - PuppetLint.configuration.send("#{check}_enabled?") + PuppetLint.configuration.send(:"#{check}_enabled?") end end diff --git a/lib/puppet-lint/configuration.rb b/lib/puppet-lint/configuration.rb index c3539ed5..df6e60e2 100644 --- a/lib/puppet-lint/configuration.rb +++ b/lib/puppet-lint/configuration.rb @@ -17,21 +17,21 @@ def self.add_check(check) # Public: Determine if the named check is enabled. # # Returns true if the check is enabled, otherwise return false. - define_method("#{check}_enabled?") do + define_method(:"#{check}_enabled?") do settings["#{check}_disabled"] != true end # Public: Disable the named check. # # Returns nothing. - define_method("disable_#{check}") do + define_method(:"disable_#{check}") do settings["#{check}_disabled"] = true end # Public: Enable the named check. # # Returns nothing. - define_method("enable_#{check}") do + define_method(:"enable_#{check}") do settings["#{check}_disabled"] = false end end @@ -92,7 +92,7 @@ def self.add_option(option) # value - The value to set the option to. # # Returns nothing. - define_method("#{option}=") do |value| + define_method(:"#{option}=") do |value| settings[option] = value end diff --git a/lib/puppet-lint/optparser.rb b/lib/puppet-lint/optparser.rb index 6931be8d..4dcb2930 100644 --- a/lib/puppet-lint/optparser.rb +++ b/lib/puppet-lint/optparser.rb @@ -117,9 +117,9 @@ def self.build(args = []) enable_checks = checks.split(',').map(&:to_sym) PuppetLint.configuration.checks.each do |check| if enable_checks.include?(check) - PuppetLint.configuration.send("enable_#{check}") + PuppetLint.configuration.send(:"enable_#{check}") else - PuppetLint.configuration.send("disable_#{check}") + PuppetLint.configuration.send(:"disable_#{check}") end end end @@ -130,13 +130,13 @@ def self.build(args = []) PuppetLint.configuration.checks.each do |check| opts.on("--no-#{check}-check", "Skip the #{check} check.") do - PuppetLint.configuration.send("disable_#{check}") + PuppetLint.configuration.send(:"disable_#{check}") end - next if PuppetLint.configuration.send("#{check}_enabled?") + next if PuppetLint.configuration.send(:"#{check}_enabled?") opts.on("--#{check}-check", "Enable the #{check} check.") do - PuppetLint.configuration.send("enable_#{check}") + PuppetLint.configuration.send(:"enable_#{check}") end end end diff --git a/lib/puppet-lint/tasks/puppet-lint.rb b/lib/puppet-lint/tasks/puppet-lint.rb index bda63e80..d1947af4 100644 --- a/lib/puppet-lint/tasks/puppet-lint.rb +++ b/lib/puppet-lint/tasks/puppet-lint.rb @@ -52,19 +52,19 @@ def define(args, &task_block) enable_checks = Array(@only_checks).map(&:to_sym) PuppetLint.configuration.checks.each do |check| if enable_checks.include?(check) - PuppetLint.configuration.send("enable_#{check}") + PuppetLint.configuration.send(:"enable_#{check}") else - PuppetLint.configuration.send("disable_#{check}") + PuppetLint.configuration.send(:"disable_#{check}") end end end Array(@disable_checks).each do |check| - PuppetLint.configuration.send("disable_#{check}") + PuppetLint.configuration.send(:"disable_#{check}") end ['with_filename', 'fail_on_warnings', 'error_level', 'log_format', 'with_context', 'fix', 'show_ignored', 'relative'].each do |config| - value = instance_variable_get("@#{config}") + value = instance_variable_get(:"@#{config}") PuppetLint.configuration.send("#{config}=".to_sym, value) unless value.nil? end