Sha256: 27e1ecc03664febbfc1499057316d06deb64245c8781fdf47394bd5a36c558d4

Contents?: true

Size: 781 Bytes

Versions: 1

Compression:

Stored size: 781 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

1 entries across 1 versions & 1 rubygems

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