Class: CustomCops::Constantize

Inherits:
RuboCop::Cop::Base
  • Object
show all
Defined in:
lib/simplycop/custom_cops/constantize.rb

Overview

This cop checks for the presence of dynamically generated constants

Examples:

#bad
"FOO_BAR".constantize

#good
FOO_BAR

Constant Summary collapse

MSG =
'Avoid dynamically creating constants.'

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



18
19
20
21
22
# File 'lib/simplycop/custom_cops/constantize.rb', line 18

def on_send(node)
  return unless constantizing?(node)

  add_offense(node.loc.selector)
end