Sha256: 0695a11ed2c593468747b53c65c79bcee91e26bb90ebc357bbb6310057d79918
Contents?: true
Size: 1 KB
Versions: 2
Compression:
Stored size: 1 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module Layout # This cop looks for trailing whitespace in the source code. # # @example # # The line in this example contains spaces after the 0. # # bad # x = 0 # # # The line in this example ends directly after the 0. # # good # x = 0 # class TrailingWhitespace < Cop include RangeHelp MSG = 'Trailing whitespace detected.'.freeze 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 def autocorrect(range) ->(corrector) { corrector.remove(range) } end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.54.0 | lib/rubocop/cop/layout/trailing_whitespace.rb |
rubocop-0.53.0 | lib/rubocop/cop/layout/trailing_whitespace.rb |