Sha256: 0467b2e0e0f04c69e7c3b1ab0392a68ed5232869cbbbd04f2aea64f67c628b11

Contents?: true

Size: 654 Bytes

Versions: 1

Compression:

Stored size: 654 Bytes

Contents

# 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_type = s[1][1][0]

          # don't check operators
          next if symbol_type == :@op

          symbol_ident = s[1][1][1]

          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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-0.6.0 lib/rubocop/cop/symbol_snake_case.rb