Sha256: 8ac35f13bf247cebf2f0f4144d510e20eba700aa17ee207543175372804da5c4

Contents?: true

Size: 780 Bytes

Versions: 2

Compression:

Stored size: 780 Bytes

Contents

# frozen_string_literal: true

PuppetLint.new_check(:lookup_in_parameter) do
  def check
    active = false
    tokens.each do |token|
      case token.type
      when :CLASS, :DEFINE
        active = 0 if token.next_code_token.type == :NAME && token.next_code_token.next_code_token.type == :LPAREN
      when :LPAREN
        active += 1 if active
      when :RPAREN
        if active
          active -= 1
          active = false if active.zero?
        end
      when :FUNCTION_NAME
        next unless active
        next unless token.value == 'lookup'
        notify :warning, {
          message: 'lookup used to set the default value of a parameter',
          line: token.line,
          column: token.column,
          token: token,
        }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
puppet-lint-lookup_in_parameter-check-1.1.0 lib/puppet-lint/plugins/lookup_in_parameter.rb
puppet-lint-lookup_in_parameter-check-1.0.0 lib/puppet-lint/plugins/lookup_in_parameter.rb