Class: PuppetLint::CheckPlugin

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet-lint/checkplugin.rb

Overview

Public: A class that contains and provides information for the puppet-lint checks.

This class should not be used directly, but instead should be inherited.

Examples

class PuppetLint::Plugin::CheckFoo < PuppetLint::CheckPlugin
end

Instance Method Summary collapse

Constructor Details

#initializeCheckPlugin

Internal: Initialise a new PuppetLint::CheckPlugin.


12
13
14
# File 'lib/puppet-lint/checkplugin.rb', line 12

def initialize
  @problems = []
end

Instance Method Details

#fix_problemsObject

Internal: Fix any problems the check plugin has detected.

Returns an Array of problem Hashes.


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/puppet-lint/checkplugin.rb', line 37

def fix_problems
  @problems.reject { |problem| problem[:kind] == :ignored }.each do |problem|
    if self.respond_to?(:fix)
      begin
        fix(problem)
      rescue PuppetLint::NoFix
        # noop
      else
        problem[:kind] = :fixed
      end
    end
  end

  @problems
end

#runObject

Internal: Check the manifest for problems and filter out any problems that should be ignored.

Returns an Array of problem Hashes.


20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/puppet-lint/checkplugin.rb', line 20

def run
  check

  @problems.each do |problem|
    if PuppetLint::Data.ignore_overrides[problem[:check]].has_key?(problem[:line])
      problem[:kind] = :ignored
      problem[:reason] = PuppetLint::Data.ignore_overrides[problem[:check]][problem[:line]]
      next
    end
  end

  @problems
end