Class: Rubocop::Cop::TrailingWhitespace

Inherits:
Cop
  • Object
show all
Defined in:
lib/rubocop/cop/trailing_whitespace.rb

Constant Summary collapse

ERROR_MESSAGE =
'Trailing whitespace detected.'

Instance Attribute Summary

Attributes inherited from Cop

#offences

Instance Method Summary collapse

Methods inherited from Cop

#add_offence, enabled?, #has_report?, inherited, #initialize, #inspect_source

Constructor Details

This class inherits a constructor from Rubocop::Cop::Cop

Instance Method Details

#inspect(file, source) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/rubocop/cop/trailing_whitespace.rb', line 8

def inspect(file, source)
  source.each_with_index do |line, index|
    if line =~ /.*[ \t]+$/
      add_offence(:convention, index, line, ERROR_MESSAGE)
    end
  end
end