Skip to content

Commit

Permalink
optimize executre_parsers usage params, bump puppet max to 8
Browse files Browse the repository at this point in the history
  • Loading branch information
mschuchard committed Jun 6, 2023
1 parent 99cc9f9 commit 920f226
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 2.3.0
- Support Puppet 8.

### 2.2.2
- Workaround Ruby passbyref issue mutating an immutable.

Expand Down
12 changes: 6 additions & 6 deletions lib/puppet_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PuppetCheck
ignored: []
}

# allow the parser methods write to the files
# allow the parser methods to write to the files
class << self
attr_accessor :files
end
Expand All @@ -27,7 +27,7 @@ def run(settings = {}, paths = [])
files = self.class.parse_paths(paths)

# parse the files
parsed_files = execute_parsers(files, settings)
parsed_files = execute_parsers(files, settings[:style], settings[:puppetlint_args], settings[:rubocop_args])

# output the diagnostic results
OutputResults.run(parsed_files.clone, settings[:output_format])
Expand Down Expand Up @@ -122,16 +122,16 @@ def self.parse_paths(paths = [])
private

# categorize and pass the files out to the parsers to determine their status
def execute_parsers(files, settings)
def execute_parsers(files, style, puppetlint_args, rubocop_args)
# check manifests
manifests, files = files.partition { |file| File.extname(file) == '.pp' }
PuppetParser.manifest(manifests, settings[:style], settings[:puppetlint_args]) unless manifests.empty?
PuppetParser.manifest(manifests, style, puppetlint_args) unless manifests.empty?
# check puppet templates
templates, files = files.partition { |file| File.extname(file) == '.epp' }
PuppetParser.template(templates) unless templates.empty?
# check ruby files
rubies, files = files.partition { |file| File.extname(file) == '.rb' }
RubyParser.ruby(rubies, settings[:style], settings[:rubocop_args]) unless rubies.empty?
RubyParser.ruby(rubies, style, rubocop_args) unless rubies.empty?
# check ruby templates
templates, files = files.partition { |file| File.extname(file) == '.erb' }
RubyParser.template(templates) unless templates.empty?
Expand All @@ -146,7 +146,7 @@ def execute_parsers(files, settings)
# DataParser.eyaml(eyamls, public, private) unless eyamls.empty?
# check misc ruby
librarians, files = files.partition { |file| File.basename(file) =~ /(?:Puppet|Module|Rake|Gem)file$/ }
RubyParser.librarian(librarians, settings[:style], settings[:rubocop_args]) unless librarians.empty?
RubyParser.librarian(librarians, style, rubocop_args) unless librarians.empty?
# ignore everything else
files.each { |file| self.class.files[:ignored].push(file.to_s) }
# return PuppetCheck.files to mitigate singleton write accessor side effects
Expand Down
2 changes: 1 addition & 1 deletion puppet-check.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
spec.require_paths = Dir['lib']

spec.required_ruby_version = '>= 2.6.0'
spec.add_dependency 'puppet', '>= 5.5', '< 8'
spec.add_dependency 'puppet', '>= 5.5', '< 9'
spec.add_dependency 'puppet-lint', '>= 2.0', '< 4'
spec.add_dependency 'reek', '~> 6.0'
spec.add_dependency 'rubocop', '~> 1.0'
Expand Down

0 comments on commit 920f226

Please sign in to comment.