class RubbyCop::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/rubbycop/cop/layout/trailing_whitespace.rb, line 22
def autocorrect(range)
  ->(corrector) { corrector.remove(range) }
end
investigate(processed_source) click to toggle source
# File lib/rubbycop/cop/layout/trailing_whitespace.rb, line 10
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, range)
  end
end