Class: PuppetLint::RakeTask

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

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ RakeTask

Returns a new instance of RakeTask.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/puppet-lint/tasks/puppet-lint.rb', line 7

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

  task :lint do
    PuppetLint.configuration.with_filename = true

    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
      end
      fail if linter.errors? || (
        linter.warnings? && PuppetLint.configuration.fail_on_warnings
      )
    end
  end
end