Class: RuboCop::Cop::Sorbet::ForbidTCast
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Sorbet::ForbidTCast
- Extended by:
- AutoCorrector
- Includes:
- RBSAssertionCorrection
- Defined in:
- lib/rubocop/cop/sorbet/forbid_t_cast.rb
Overview
Disallows using T.cast anywhere.
Set AutocorrectToRBS: true to replace supported calls with RBS inline comments.
Constant Summary collapse
- MSG =
"Do not use `T.cast`."- RESTRICT_ON_SEND =
[:cast].freeze
Constants included from RBSAssertionCorrection
RBSAssertionCorrection::COMMENT_START, RBSAssertionCorrection::NEWLINES
Instance Method Summary collapse
- #on_send(node) ⇒ Object (also: #on_csend)
- #t_cast?(node) ⇒ Object
Instance Method Details
#on_send(node) ⇒ Object Also known as: on_csend
29 30 31 32 33 |
# File 'lib/rubocop/cop/sorbet/forbid_t_cast.rb', line 29 def on_send(node) return unless t_cast?(node) add_offense(node) { |corrector| autocorrect_t_cast_to_rbs(corrector, node) } end |
#t_cast?(node) ⇒ Object
27 |
# File 'lib/rubocop/cop/sorbet/forbid_t_cast.rb', line 27 def_node_matcher(:t_cast?, "(send (const nil? :T) :cast _ _)") |