class Object

Public Instance Methods

check() click to toggle source
# File lib/puppet-lint/plugins/check_abc_size.rb, line 4
def check
  @warn = PuppetLint.configuration.metrics_abc_warning || 30
  @fail = PuppetLint.configuration.metrics_abc_error || 100

  parser = Puppet::Pops::Parser::EvaluatingParser.new
  program = parser.parse_string(manifest_lines.join("\n"))
  abc_metric = PuppetLint::Metrics::Abc.new

  abc_size = abc_metric.compute(program.model).last

  notification = {
    :message => "assignment branch condition size is #{abc_size}",
    :line    => 0,
    :column  => 0,
  }

  if @fail > abc_size
    if abc_size >= @warn
      notify :warning, notification
    end
  else
    notify :error, notification
  end
end