Class: Rubocop::Cop::LeadingCommentSpace
- Defined in:
- lib/rubocop/cop/leading_comment_space.rb
Constant Summary collapse
- ERROR_MESSAGE =
'Missing space after #.'
Instance Attribute Summary
Attributes inherited from Cop
#correlations, #debug, #disabled_lines, #offences
Instance Method Summary collapse
Methods inherited from Cop
#add_offence, cop_name, #has_report?, inherited, #initialize, #name
Constructor Details
This class inherits a constructor from Rubocop::Cop::Cop
Instance Method Details
#inspect(file, source, tokens, sexp) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rubocop/cop/leading_comment_space.rb', line 8 def inspect(file, source, tokens, sexp) tokens.each_index do |ix| t = tokens[ix] if t.type == :on_comment && t.text =~ /^#+[^#\s]/ unless t.text.start_with?('#!') && t.pos.lineno == 1 add_offence(:convention, t.pos.lineno, ERROR_MESSAGE) end end end end |