Sha256: 699a3f6832eaf1cba74a2045d0eedc7e9e6d9d4dbafe6e48ff8d27aed3876b46

Contents?: true

Size: 730 Bytes

Versions: 9

Compression:

Stored size: 730 Bytes

Contents

# encoding: utf-8

module RuboCop
  module Cop
    module Style
      # This cop looks for trailing whitespace in the source code.
      class TrailingWhitespace < Cop
        MSG = 'Trailing whitespace detected.'

        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

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rubocop-0.35.1 lib/rubocop/cop/style/trailing_whitespace.rb
rubocop-0.35.0 lib/rubocop/cop/style/trailing_whitespace.rb
rubocop-0.34.2 lib/rubocop/cop/style/trailing_whitespace.rb
rubocop-0.34.1 lib/rubocop/cop/style/trailing_whitespace.rb
rubocop-0.34.0 lib/rubocop/cop/style/trailing_whitespace.rb
rubocop-0.33.0 lib/rubocop/cop/style/trailing_whitespace.rb
rubocop-0.32.1 lib/rubocop/cop/style/trailing_whitespace.rb
rubocop-0.32.0 lib/rubocop/cop/style/trailing_whitespace.rb
rubocop-0.31.0 lib/rubocop/cop/style/trailing_whitespace.rb