Class: RuboCop::Cop::Sorbet::ForbidTLet

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Includes:
RBSAssertionCorrection
Defined in:
lib/rubocop/cop/sorbet/forbid_t_let.rb

Overview

Disallows using T.let anywhere. Set AutocorrectToRBS: true to replace supported calls with RBS inline comments.

Examples:


# bad
T.let(foo, Integer)

# good
foo #: Integer

Constant Summary collapse

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

Constants included from RBSAssertionCorrection

RBSAssertionCorrection::COMMENT_START, RBSAssertionCorrection::NEWLINES

Instance Method Summary collapse

Instance Method Details

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



29
30
31
32
33
# File 'lib/rubocop/cop/sorbet/forbid_t_let.rb', line 29

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

  add_offense(node) { |corrector| autocorrect_t_let_to_rbs(corrector, node) }
end

#t_let?(node) ⇒ Object



27
# File 'lib/rubocop/cop/sorbet/forbid_t_let.rb', line 27

def_node_matcher(:t_let?, "(send (const nil? :T) :let _ _)")