Sha256: 3b3bd78e5be7b3d71921c0d6ff8422a51120b3f5a6da5575a8b4de66cc7616b2

Contents?: true

Size: 889 Bytes

Versions: 3

Compression:

Stored size: 889 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_types) do
  def manifests
    Dir.glob('./**/manifests/**/*.pp')
  end

  def check
    m = path.match(%r{.*/[^/]+/lib/puppet/type/(.+)\.rb$})
    return if m.nil?

    type_name = m.captures[0]

    puppetdb = PuppetGhostbuster::PuppetDB.new
    return if puppetdb.resources.include? type_name.capitalize

    notify :warning, {
      message: "Type #{type_name.capitalize} seems unused",
      line: 1,
      column: 1,
    }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
puppet-ghostbuster-1.2.1 lib/puppet-lint/plugins/check_ghostbuster_types.rb
puppet-ghostbuster-1.2.0 lib/puppet-lint/plugins/check_ghostbuster_types.rb
puppet-ghostbuster-1.1.0 lib/puppet-lint/plugins/check_ghostbuster_types.rb