Class: Rubocop::Cop::Style::AsciiComments

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

Overview

This cop checks for non-ascii (non-English) characters in comments.

Constant Summary collapse

MSG =
'Use only ascii symbols in comments.'

Instance Attribute Summary

Attributes inherited from Cop

#autocorrect, #corrections, #debug, #disabled_lines, #offences

Instance Method Summary collapse

Methods inherited from Cop

#add_offence, all, #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

#investigate(processed_source) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/rubocop/cop/style/ascii_comments.rb', line 11

def investigate(processed_source)
  processed_source.comments.each do |comment|
    if comment.text =~ /[^\x00-\x7f]/
      add_offence(:convention, comment.loc.expression, MSG)
    end
  end
end