Class: Rubocop::Cop::AsciiIdentifiers

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

Constant Summary collapse

MSG =
'Use only ascii symbols in identifiers.'

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, #name, #on_comment

Constructor Details

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

Instance Method Details

#inspect(source, tokens, ast, comments) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/rubocop/cop/ascii_identifiers.rb', line 10

def inspect(source, tokens, ast, comments)
  tokens.each do |t|
    if t.type == :tIDENTIFIER && t.text =~ /[^\x00-\x7f]/
      add_offence(:convention, t.pos.line, MSG)
    end
  end
end