Class: Rubocop::Cop::Style::TrailingWhitespace
- Defined in:
- lib/rubocop/cop/style/trailing_whitespace.rb
Overview
This cop looks for trailing whitespace in the source code.
Constant Summary collapse
- MSG =
'Trailing whitespace detected.'
Instance Attribute Summary
Attributes inherited from Cop
#autocorrect, #debug, #disabled_lines, #offences
Instance Method Summary collapse
Methods inherited from Cop
#add_offence, #autocorrect_action, cop_name, cop_type, #do_autocorrect, #ignore_node, inherited, #initialize, lint?, #name, rails?, style?
Constructor Details
This class inherits a constructor from Rubocop::Cop::Cop
Instance Method Details
#inspect(source_buffer, source, tokens, ast, comments) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rubocop/cop/style/trailing_whitespace.rb', line 10 def inspect(source_buffer, source, tokens, ast, comments) source.each_with_index do |line, index| if line =~ /.*[ \t]+$/ add_offence(:convention, source_range(source_buffer, source[0...index], line.rstrip.length, line.length - line.rstrip.length), MSG) end end end |