Sha256: 31024191bbb6c658c82f6f8b1ebc904bec81d5d6861a621722534a32455f8409
Contents?: true
Size: 564 Bytes
Versions: 4
Compression:
Stored size: 564 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop class SymbolName < Cop MSG = 'Use snake_case for symbols.' SNAKE_CASE = /^[\da-z_]+[!?=]?$/ CAMEL_CASE = /^[A-Z][A-Za-z\d]*$/ def allow_camel_case? self.class.config['AllowCamelCase'] end def on_sym(node) sym_name = node.to_a[0] return unless sym_name =~ /^[a-zA-Z]/ return if sym_name =~ SNAKE_CASE return if allow_camel_case? && sym_name =~ CAMEL_CASE add_offence(:convention, node.loc.line, MSG) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.8.3 | lib/rubocop/cop/symbol_name.rb |
rubocop-0.8.2 | lib/rubocop/cop/symbol_name.rb |
rubocop-0.8.1 | lib/rubocop/cop/symbol_name.rb |
rubocop-0.8.0 | lib/rubocop/cop/symbol_name.rb |