Class: RuboCop::Cop::Sorbet::ForbidTSig
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Sorbet::ForbidTSig
- Defined in:
- lib/rubocop/cop/sorbet/forbid_t_sig.rb
Overview
Forbids ‘extend T::Sig` and `include T::Sig` in classes and modules.
This is useful when using RBS or RBS-inline syntax for type signatures, where ‘T::Sig` is not needed and including it is redundant.
Constant Summary collapse
- MSG =
"Do not use `%<method>s T::Sig`."- RESTRICT_ON_SEND =
[:extend, :include].freeze
Instance Method Summary collapse
- #on_send(node) ⇒ Object (also: #on_csend)
- #t_sig?(node) ⇒ Object
Instance Method Details
#on_send(node) ⇒ Object Also known as: on_csend
35 36 37 38 39 |
# File 'lib/rubocop/cop/sorbet/forbid_t_sig.rb', line 35 def on_send(node) return unless t_sig?(node) add_offense(node, message: format(MSG, method: node.method_name)) end |
#t_sig?(node) ⇒ Object
31 32 33 |
# File 'lib/rubocop/cop/sorbet/forbid_t_sig.rb', line 31 def_node_matcher :t_sig?, "(send _ {:extend :include} (const (const {nil? | cbase} :T) :Sig))\n" |