<commit_before># encoding: utf-8

module Rubocop
  module Cop
    class SymbolSnakeCase < Cop
      ERROR_MESSAGE = 'Use snake_case for symbols.'
      SNAKE_CASE = /^@?[\da-z_]+[!?=]?$/

      def inspect(file, source, tokens, sexp)
        each(:symbol_literal, sexp) do |s|
          symbol_ident = s[1][1][1]

          # handle a couple of special cases
          next if ['!', '[]', '**'].include?(symbol_ident)

          unless symbol_ident =~ SNAKE_CASE
            line_no = s[1][1][2].lineno
            add_offence(:convention,
                        line_no,
                        ERROR_MESSAGE)
          end
        end
      end
    end
  end
end
<commit_msg>Extend handling of special symbol names<commit_after># encoding: utf-8

module Rubocop
  module Cop
    class SymbolSnakeCase < Cop
      ERROR_MESSAGE = 'Use snake_case for symbols.'
      SNAKE_CASE = /^@?[\da-z_]+[!?=]?$/
      OPERATORS = %w(! + - % * ** [])

      def inspect(file, source, tokens, sexp)
        each(:symbol_literal, sexp) do |s|
          symbol_ident = s[1][1][1]

          # handle a couple of special cases
          next if OPERATORS.include?(symbol_ident)

          unless symbol_ident =~ SNAKE_CASE
            line_no = s[1][1][2].lineno
            add_offence(:convention,
                        line_no,
                        ERROR_MESSAGE)
          end
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.11473087818696884, 'fraction_numerical': 0.009915014164305949, 'mean_word_length': 1.759765625, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4211480', 'n_tokens_mistral': 456, 'n_tokens_neox': 444, 'n_words': 109}