diff --git a/Rakefile b/Rakefile index 0f710fd..4fd739c 100644 --- a/Rakefile +++ b/Rakefile @@ -17,3 +17,33 @@ task :validate do sh "erb -P -x -T '-' #{template} | ruby -c" 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 +