lib/puppet-check/puppet_parser.rb in puppet-check-1.3.0 vs lib/puppet-check/puppet_parser.rb in puppet-check-1.3.1

- old
+ new

@@ -2,16 +2,16 @@ require_relative '../puppet-check' # executes diagnostics on puppet files class PuppetParser # checks puppet (.pp) - def self.manifest(files) + def self.manifest(files, future, style, pl_args) require 'puppet/face' # prepare the Puppet settings for the error checking Puppet.initialize_settings unless Puppet.settings.app_defaults_initialized? - Puppet[:parser] = 'future' if PuppetCheck.future_parser && (Puppet::PUPPETVERSION.to_i < 4) + Puppet[:parser] = 'future' if future && (Puppet::PUPPETVERSION.to_i < 4) files.each do |file| # setup error logging and collection errors = [] Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(errors)) @@ -27,19 +27,19 @@ # initialize warnings with output from the parser if it exists, since the output is warnings if Puppet::Face did not trigger a SystemExit warnings = errors.empty? ? "#{file}:" : "#{file}:\n#{errors.map(&:to_s).join("\n").gsub("#{File.absolute_path(file)}:", '')}" Puppet::Util::Log.close_all # check puppet style - if PuppetCheck.style_check + if style require 'puppet-lint' require 'puppet-lint/optparser' # check for invalid arguments to PuppetLint begin - PuppetLint::OptParser.build.parse!(PuppetCheck.puppetlint_args.clone) + PuppetLint::OptParser.build.parse!(pl_args.clone) rescue OptionParser::InvalidOption - raise "puppet-lint: invalid option supplied among #{PuppetCheck.puppetlint_args.join(' ')}" + raise "puppet-lint: invalid option supplied among #{pl_args.join(' ')}" end # prepare the PuppetLint object for style checks puppet_lint = PuppetLint.new puppet_lint.file = file @@ -59,10 +59,10 @@ def self.template(files) require 'puppet/pops' files.each do |file| # puppet before version 4 cannot check template syntax - next PuppetCheck.ignored_files.push("#{file}: ignored due to Puppet < 4.0.0") if Puppet::PUPPETVERSION.to_i < 4 + next PuppetCheck.ignored_files.push("#{file}: ignored due to Puppet < 4") if Puppet::PUPPETVERSION.to_i < 4 # check puppet template syntax begin # credits to gds-operations/puppet-syntax for the parser function call Puppet::Pops::Parser::EvaluatingParser::EvaluatingEppParser.new.parse_file(file)