Sha256: 698418f10261c2cf11e02a8df5c63a2a755a77d6380b7c718763b686c8533b3d

Contents?: true

Size: 711 Bytes

Versions: 1

Compression:

Stored size: 711 Bytes

Contents

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

    tokens.each_with_index do |token, _token_idx|
      next unless 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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
puppet-lint-absolute_classname-check-4.0.0 lib/puppet-lint/plugins/check_classname_reference.rb