class RuboCop::Cop::Layout::TrailingWhitespace

This cop looks for trailing whitespace in the source code.

Constants

MSG

Public Instance Methods

autocorrect(range) click to toggle source
# File lib/rubocop/cop/layout/trailing_whitespace.rb, line 21
def autocorrect(range)
  ->(corrector) { corrector.remove(range) }
end
investigate(processed_source) click to toggle source
# File lib/rubocop/cop/layout/trailing_whitespace.rb, line 9
def investigate(processed_source)
  processed_source.lines.each_with_index do |line, index|
    next unless line.end_with?(' ', "\t")

    range = source_range(processed_source.buffer,
                         index + 1,
                         (line.rstrip.length)...(line.length))

    add_offense(range, location: range)
  end
end