Sha256: 438f37dfa1a85b2517becf36d9c50559484017f927398b6fb0fcefd2ec45e22a
Contents?: true
Size: 1011 Bytes
Versions: 3
Compression:
Stored size: 1011 Bytes
Contents
require 'puppet-ghostbuster/puppetdb' class PuppetLint::Checks def load_data(path, content) lexer = PuppetLint::Lexer.new PuppetLint::Data.path = path begin PuppetLint::Data.manifest_lines = content.split("\n", -1) PuppetLint::Data.tokens = lexer.tokenise(content) PuppetLint::Data.parse_control_comments rescue PuppetLint::Data.tokens = [] end end end PuppetLint.new_check(:ghostbuster_defines) do def check return if path.match(%r{^\./(:?[^/]+/){2}?manifests/.+$}).nil? puppetdb = PuppetGhostbuster::PuppetDB.new defined_type_indexes.each do |define_idx| title_token = define_idx[:name_token] type = title_token.value.split('::').map(&:capitalize).join('::') return if puppetdb.client.request('resources', [:'=', 'type', type]).data.size > 0 notify :warning, { :message => "Define #{type} seems unused", :line => title_token.line, :column => title_token.column, } end end end
Version data entries
3 entries across 3 versions & 1 rubygems