Sha256: ca6b1c4dd25375cdbdc6c3d65d5e259232309c3e7da075d1bca21526045acdd0

Contents?: true

Size: 928 Bytes

Versions: 3

Compression:

Stored size: 928 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_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.client.request('resources', [:'=', 'type', type_name.capitalize]).data.size > 0

    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-0.8.0 lib/puppet-lint/plugins/check_ghostbuster_types.rb
puppet-ghostbuster-0.7.3 lib/puppet-lint/plugins/check_ghostbuster_types.rb
puppet-ghostbuster-0.7.2 lib/puppet-lint/plugins/check_ghostbuster_types.rb