Class: RuboCop::Cop::Sorbet::ForbidExtendTSigHelpersInShims
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Sorbet::ForbidExtendTSigHelpersInShims
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp
- Defined in:
- lib/rubocop/cop/sorbet/rbi/forbid_extend_t_sig_helpers_in_shims.rb
Overview
Ensures RBI shims do not include a call to extend T::Sig or to extend T::Helpers
Constant Summary collapse
- MSG =
"Extending T::Sig or T::Helpers in a shim is unnecessary"
- RESTRICT_ON_SEND =
[:extend].freeze
Instance Method Summary collapse
Instance Method Details
#extend_t_sig_or_helpers?(node) ⇒ Object
33 34 35 |
# File 'lib/rubocop/cop/sorbet/rbi/forbid_extend_t_sig_helpers_in_shims.rb', line 33 def_node_matcher :extend_t_sig_or_helpers?, <<~PATTERN (send nil? :extend (const (const nil? :T) {:Sig :Helpers})) PATTERN |
#on_send(node) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/rubocop/cop/sorbet/rbi/forbid_extend_t_sig_helpers_in_shims.rb', line 37 def on_send(node) extend_t_sig_or_helpers?(node) do add_offense(node) do |corrector| corrector.remove(range_by_whole_lines(node.source_range, include_final_newline: true)) end end end |