class RuboCop::Cop::Sorbet::ConstantsFromStrings

{ “User” => User }.fetch(class_name)
# good
end
raise ArgumentError
else
User
when “User”
case class_name
# good
const_get(class_name)
# bad
constants.detect { |c| c.name == “User” }
# bad
class_name.constantize
# bad
@example
expresses which values the constant can have.
more IDE-friendly, and more predictable. It leads to code that clearly
The goal of this cop is to make the code easier to statically analyze,
such as constantize, const_get, and constants.
Disallows the calls that are used to get constants fom Strings

def on_send(node)

def on_send(node)
  add_offense(node.selector, message: format(MSG, method_name: node.method_name))
end