Class: Rubocop::Cop::ConstantName
- Defined in:
- lib/rubocop/cop/constant_name.rb
Constant Summary collapse
- MSG =
'Use SCREAMING_SNAKE_CASE for constants.'
- SNAKE_CASE =
/^[\dA-Z_]+$/
Instance Attribute Summary
Attributes inherited from Cop
#debug, #disabled_lines, #offences
Instance Method Summary collapse
Methods inherited from Cop
#add_offence, cop_name, #has_report?, inherited, #initialize, #inspect, #name, #on_comment
Constructor Details
This class inherits a constructor from Rubocop::Cop::Cop
Instance Method Details
#on_casgn(node) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rubocop/cop/constant_name.rb', line 9 def on_casgn(node) _scope, const_name, value = *node # we cannot know the result of method calls line # NewClass = something_that_returns_a_class if value.type != :send && const_name !~ SNAKE_CASE add_offence(:convention, node.loc.line, MSG) end super end |