Skip to content

Instantly share code, notes, and snippets.

@pserrano
Forked from rtyler/gist:3041462
Last active August 29, 2015 14:10
Show Gist options
  • Save pserrano/2a919f248bf74fe31972 to your computer and use it in GitHub Desktop.
Save pserrano/2a919f248bf74fe31972 to your computer and use it in GitHub Desktop.
LINT_IGNORES = ['rvm']
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
success = true
linter = PuppetLint.new
linter.configuration.log_format =
'%{path}:%{linenumber}:%{check}:%{KIND}:%{message}'
lintrc = ".puppet-lintrc"
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['**/*.pp'].each do |puppet_file|
if puppet_file.start_with? 'modules'
parts = puppet_file.split('/')
module_name = parts[1]
next if LINT_IGNORES.include? module_name
end
puts "Evaluating code style for #{puppet_file}"
linter.file = puppet_file
linter.run
success = false if linter.errors?
end
abort "Checking puppet module code style FAILED" if success.is_a?(FalseClass)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment