class RuboCop::Cop::Style::AsciiComments
in comments.
This cop checks for non-ascii (non-English) characters
def first_non_ascii_chars(string)
def first_non_ascii_chars(string) string.match(/[^[:ascii:]]+/).to_s end
def first_offense_range(comment)
def first_offense_range(comment) expression = comment.loc.expression first_offense = first_non_ascii_chars(comment.text) start_position = expression.begin_pos + comment.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.comments.each do |comment| unless comment.text.ascii_only? add_offense(comment, first_offense_range(comment)) end end end