Sha256: 3b6c20ea5e7b69e5d829973c41b74d6a6c3b8b666444187cacce07118f036f65
Contents?: true
Size: 960 Bytes
Versions: 2
Compression:
Stored size: 960 Bytes
Contents
PuppetLint.new_check(:ghostbuster_facts) do def manifests Dir.glob('./**/manifests/**/*.pp') end def templates Dir.glob('./**/templates/**/*').select{ |f| File.file? f } end def check m = path.match(%r{.*/([^/]+)/lib/facter/(.+)$}) return if m.nil? File.readlines(path).grep(%r{Facter.add\(["']([^"']+)["']\)}).each do |line| fact_name = line.match(%r{Facter.add\(["']([^"']+)["']\)}).captures[0] found = false manifests.each do |manifest| found = true if File.readlines(manifest).grep(%r{\$\{?::#{fact_name}\}?}).size > 0 break if found end templates.each do |template| found = true if File.readlines(template).grep(%r{@#{fact_name}}).size > 0 break if found end unless found notify :warning, { :message => "Fact #{fact_name} seems unused", :line => 1, :column => 1, } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
puppet-ghostbuster-0.7.1 | lib/puppet-lint/plugins/check_ghostbuster_facts.rb |
puppet-ghostbuster-0.7.0 | lib/puppet-lint/plugins/check_ghostbuster_facts.rb |