Class: Rubocop::Cop::LeadingCommentSpace

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

Constant Summary collapse

MSG =
'Missing space after #.'

Instance Attribute Summary

Attributes inherited from Cop

#debug, #disabled_lines, #offences

Instance Method Summary collapse

Methods inherited from Cop

#add_offence, cop_name, #has_report?, #ignore_node, inherited, #initialize, #inspect, #name

Constructor Details

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

Instance Method Details

#on_comment(c) ⇒ Object



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

def on_comment(c)
  if c.text =~ /^#+[^#\s]/
    unless c.text.start_with?('#!') && c.loc.line == 1
      add_offence(:convention, c.loc.line, MSG)
    end
  end
end