Add lint:ci task

This commit is contained in:
2014-11-24 17:09:32 +00:00
parent 2076d4cdaa
commit a7d702a245

View File

@@ -17,3 +17,33 @@ task :validate do
sh "erb -P -x -T '-' #{template} | ruby -c" sh "erb -P -x -T '-' #{template} | ruby -c"
end end
end end
namespace :lint do
desc "Check puppet module code style."
task :ci do
begin
require 'puppet-lint'
rescue LoadError
fail 'Cannot load puppet-lint, did you install it?'
end
linter = PuppetLint.new
linter.configuration.log_format =
'%{path}:%{linenumber}:%{check}:%{KIND}:%{message}'
lintrc = ".puppet-lint.rc"
if File.file?(lintrc)
File.read(lintrc).each_line do |line|
check = line.sub(/--no-([a-zA-Z0-9_]*)-check/, '\1').chomp
linter.configuration.send("disable_#{check}")
end
end
FileList['manifests/**/*.pp','modules/**/*.pp'].exclude(/fixtures/).each do |puppet_file|
linter.file = puppet_file
linter.run
linter.print_problems
end
end
end