Class: RuboCop::Cop::Sorbet::ForbidTAbsurd

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

Overview

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

Examples:


# bad
T.absurd(foo)

# good
foo #: absurd

Constant Summary collapse

MSG =
"Do not use `T.absurd`."
RESTRICT_ON_SEND =
[:absurd].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



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

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

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

#t_absurd?(node) ⇒ Object



26
# File 'lib/rubocop/cop/sorbet/forbid_t_absurd.rb', line 26

def_node_matcher(:t_absurd?, "(send (const nil? :T) :absurd _)")