Sha256: a0472f41fe583cb54bb163d6e1e10ae1645df1930864aacce44a723990a4954c
Contents?: true
Size: 971 Bytes
Versions: 3
Compression:
Stored size: 971 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 StandardError 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.resources.include? type 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