Class: PuppetValidator::Validators::Lint
- Inherits:
-
Object
- Object
- PuppetValidator::Validators::Lint
- Defined in:
- lib/puppet-validator/validators/lint.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(settings) ⇒ Lint
constructor
A new instance of Lint.
-
#validate(data, checks = nil) ⇒ Object
This global configuration means it’s a race condition.
Constructor Details
#initialize(settings) ⇒ Lint
Returns a new instance of Lint.
4 5 6 7 |
# File 'lib/puppet-validator/validators/lint.rb', line 4 def initialize(settings) @logger = settings.logger @disabled = settings.disabled_lint_checks end |
Class Method Details
.all_checks ⇒ Object
42 43 44 45 |
# File 'lib/puppet-validator/validators/lint.rb', line 42 def self.all_checks # sanitize because reasonss PuppetLint.configuration.checks.map {|check| check.to_s} end |
Instance Method Details
#validate(data, checks = nil) ⇒ Object
This global configuration means it’s a race condition. TODO: We should isolate this.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/puppet-validator/validators/lint.rb', line 11 def validate(data, checks = nil) begin if checks @logger.info "Disabling checks: #{(PuppetValidator::Validators::Lint.all_checks - checks).inspect}" checks.each do |check| PuppetLint.configuration.send("enable_#{check}") end (PuppetValidator::Validators::Lint.all_checks - checks).each do |check| PuppetLint.configuration.send("disable_#{check}") end else @logger.info "Disabling checks: #{@disabled.inspect}" @disabled.each do |check| PuppetLint.configuration.send("disable_#{check}") end end linter = PuppetLint.new linter.code = data linter.run linter.print_problems linter.problems rescue => detail @logger.warn detail. [] end end |