Class: Rubocop::Cop::Style::LineContinuation

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

Overview

This cop checks for uses of the line continuation character.

This check has to be refined or retired, since it doesn't make a lot of sense without inspection of its context.

Constant Summary collapse

MSG =
'Avoid the use of the line continuation character(\).'

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



13
14
15
16
17
18
19
20
21
22
# File 'lib/rubocop/cop/style/line_continuation.rb', line 13

def inspect(source_buffer, source, tokens, ast, comments)
  source.each_with_index do |line, index|
    if line =~ /.*\\\z/
      add_offence(:convention,
                  source_range(source_buffer, source[0...index],
                               line.length - 1, 1),
                  MSG)
    end
  end
end