Skip to content

Commit

Permalink
Merge pull request #181 from puppetlabs/CAT-1653-Fix_rubocop
Browse files Browse the repository at this point in the history
(CAT-1653) Fix Rubocop issues
  • Loading branch information
jordanbreen28 authored Dec 19, 2023
2 parents 65b4d77 + ff701bc commit cc5074c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/puppet-lint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet-lint/checks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions lib/puppet-lint/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions lib/puppet-lint/optparser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lib/puppet-lint/tasks/puppet-lint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit cc5074c

Please sign in to comment.