Class: RuboCop::Cop::Sorbet::ForbidTCast

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/sorbet/forbid_t_cast.rb

Overview

Disallows using ‘T.cast` anywhere.

Examples:


# bad
T.cast(foo, Integer)

# good
foo #: as Integer

Constant Summary collapse

MSG =
"Do not use `T.cast`."
RESTRICT_ON_SEND =
[:cast].freeze

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object Also known as: on_csend



24
25
26
# File 'lib/rubocop/cop/sorbet/forbid_t_cast.rb', line 24

def on_send(node)
  add_offense(node) if t_cast?(node)
end

#t_cast?(node) ⇒ Object



22
# File 'lib/rubocop/cop/sorbet/forbid_t_cast.rb', line 22

def_node_matcher(:t_cast?, "(send (const nil? :T) :cast _ _)")