From e2a78aea79d57ce966e56dd7662e444fa44415ce Mon Sep 17 00:00:00 2001 From: Matt Schuchard Date: Mon, 15 Apr 2024 10:59:21 -0400 Subject: [PATCH] optimize default settings assignment --- lib/puppet_check.rb | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/lib/puppet_check.rb b/lib/puppet_check.rb index 2b177d2..35de260 100644 --- a/lib/puppet_check.rb +++ b/lib/puppet_check.rb @@ -73,29 +73,26 @@ def run(settings = {}, paths = []) # establish default settings def self.defaults(settings = {}) private_class_method :method - # initialize fail on warning, style check, and regression check bools - settings[:fail_on_warning] ||= false - settings[:style] ||= false - settings[:smoke] ||= false - settings[:regression] ||= false - # initialize ssl keys for eyaml checks - settings[:public] ||= nil - settings[:private] ||= nil - - # initialize output format option - settings[:output_format] ||= 'text' - - # initialize octocatalog-diff options - settings[:octoconfig] ||= '.octocatalog-diff.cfg.rb' - settings[:octonodes] ||= %w[localhost.localdomain] - - # initialize style arg arrays - settings[:puppetlint_args] ||= [] - settings[:rubocop_args] ||= [] - - # return update settings - settings + # return settings with defaults where unspecified + { + # initialize fail on warning, style check, and regression check bools + fail_on_warning: false, + style: false, + smoke: false, + regression: false, + # initialize ssl keys for eyaml checks + public: nil, + private: nil, + # initialize output format option + output_format: 'text', + # initialize octocatalog-diff options + octoconfig: '.octocatalog-diff.cfg.rb', + octonodes: %w[localhost.localdomain], + # initialize style arg arrays + puppetlint_args: [], + rubocop_args: [] + }.merge(settings) end # parse the paths and return the array of files