class RuboCop::Cop::Style::TrailingWhitespace

This cop looks for trailing whitespace in the source code.

def autocorrect(range)

def autocorrect(range)
  ->(corrector) { corrector.remove(range) }
end

def investigate(processed_source)

def investigate(processed_source)
  processed_source.lines.each_with_index do |line, index|
    next unless line =~ /.*[ \t]+$/
    range = source_range(processed_source.buffer,
                         index + 1,
                         (line.rstrip.length)...(line.length))
    add_offense(range, range)
  end
end