class Object

Public Instance Methods

after_bracket_tokens() click to toggle source
# File lib/puppet-lint/plugins/tools.rb, line 11
def after_bracket_tokens
  %i[RBRACK RPAREN SEMIC COMMA COLON DOT NEWLINE DQMID DQPOST LBRACK]
end
check() click to toggle source
# File lib/puppet-lint/plugins/check_manifest_whitespace_arrow_spaces.rb, line 4
def check
  tokens.select { |token| token.type == :FARROW }.each do |token|
    next_token = token.next_token

    next unless next_token && !is_single_space(next_token)

    notify(
      :error,
      message: 'there should be a single space after an arrow',
      line: next_token.line,
      column: next_token.column,
      token: next_token,
    )
  end
end
fix(problem) click to toggle source
# File lib/puppet-lint/plugins/check_manifest_whitespace_arrow_spaces.rb, line 20
def fix(problem)
  token = problem[:token]

  if token.type == :WHITESPACE
    token.value = ' '
    return
  end

  add_token(tokens.index(token), new_single_space)
end
is_single_space(token) click to toggle source
# File lib/puppet-lint/plugins/tools.rb, line 3
def is_single_space(token)
  token.type == :WHITESPACE && token.value == ' '
end
new_single_space() click to toggle source
# File lib/puppet-lint/plugins/tools.rb, line 7
def new_single_space
  PuppetLint::Lexer::Token.new(:WHITESPACE, ' ', 0, 0)
end
next_non_space_token(token) click to toggle source
# File lib/puppet-lint/plugins/tools.rb, line 21
def next_non_space_token(token)
  while token = token.next_token
    return token unless %i[WHITESPACE INDENT NEWLINE].include?(token.type)
  end
end
prev_non_space_token(token) click to toggle source
# File lib/puppet-lint/plugins/tools.rb, line 15
def prev_non_space_token(token)
  while token = token.prev_token
    return token unless %i[WHITESPACE INDENT NEWLINE].include?(token.type)
  end
end