Sha256: 82c20a35d08d31a91a8220261b31c3be4ef83113808802aa4a08165805cd2420

Contents?: true

Size: 733 Bytes

Versions: 3

Compression:

Stored size: 733 Bytes

Contents

PuppetLint.new_check(:relative_classname_reference) do
  def check
    message = 'absolute class name reference'

    tokens.each_with_index do |token, token_idx|
      if token.type == :TYPE and token.value == 'Class' and token.next_code_token.type == :LBRACK
        s = token.next_code_token
        while s.type != :RBRACK
          if (s.type == :NAME || s.type == :SSTRING) && s.value.start_with?('::')
            notify :warning, {
              message: message,
              line: s.line,
              column: s.column,
              token: s
            }
          end
          s = s.next_token
        end
      end
    end
  end

  def fix(problem)
    problem[:token].value = problem[:token].value[2..-1]
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
puppet-lint-absolute_classname-check-3.1.0 lib/puppet-lint/plugins/check_classname_reference.rb
puppet-lint-absolute_classname-check-3.0.1 lib/puppet-lint/plugins/check_classname_reference.rb
puppet-lint-absolute_classname-check-3.0.0 lib/puppet-lint/plugins/check_classname_reference.rb