class RuboCop::Cop::Naming::AsciiIdentifiers


# good<br><br>params # Arabic character (non-ascii)
# bad
height = 10
# good
신장 = 10 # Hangul character (non-ascii)
# bad
end
def say_hello
# good
end
def hello_🍣 # Emoji (non-ascii)
# bad
end
def こんにちはと言う # Japanese character (non-ascii)
# bad
end
def καλημερα # Greek alphabet (non-ascii)
# bad
@example
This cop checks for non-ascii characters in identifier names.

def first_non_ascii_chars(string)

def first_non_ascii_chars(string)
  string.match(/[^[:ascii:]]+/).to_s
end

def first_offense_range(identifier)

def first_offense_range(identifier)
  expression    = identifier.pos
  first_offense = first_non_ascii_chars(identifier.text)
  start_position = expression.begin_pos +
                   identifier.text.index(first_offense)
  end_position   = start_position + first_offense.length
  range_between(start_position, end_position)
end

def investigate(processed_source)

def investigate(processed_source)
  processed_source.each_token do |token|
    next unless token.type == :tIDENTIFIER && !token.text.ascii_only?
    add_offense(token, location: first_offense_range(token))
  end
end