Class: PuppetLint::RakeTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/puppet-lint/tasks/puppet-lint.rb

Overview

Public: A Rake task that can be loaded and used with everything you need.

Examples

require 'puppet-lint'
PuppetLint::RakeTask.new

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ RakeTask

Public: Initialise a new PuppetLint::RakeTask.

args - Not used.

Example

PuppetLint::RakeTask.new


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/puppet-lint/tasks/puppet-lint.rb', line 21

def initialize(*args)
  desc 'Run puppet-lint'

  task :lint do
    PuppetLint.configuration.with_filename = true
    PuppetLint::OptParser.build

    RakeFileUtils.send(:verbose, true) do
      linter = PuppetLint.new
      matched_files = FileList['**/*.pp']

      if ignore_paths = PuppetLint.configuration.ignore_paths
        matched_files = matched_files.exclude(*ignore_paths)
      end

      matched_files.to_a.each do |puppet_file|
        linter.file = puppet_file
        linter.run
        linter.print_problems
      end
      abort if linter.errors? || (
        linter.warnings? && PuppetLint.configuration.fail_on_warnings
      )
    end
  end
end