Module: RuboCop::Cop::Sorbet::SignatureHelp

Overview

Mixin for writing cops for signatures, providing a signature? node matcher and an on_signature trigger.

Instance Method Summary collapse

Instance Method Details

#bare_sig?(node) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/rubocop/cop/sorbet/mixin/signature_help.rb', line 16

def_node_matcher(:bare_sig?, "(block (send\n  nil?\n  :sig\n  (sym :final)?\n) (args) ...)\n")

#on_block(node) ⇒ Object Also known as: on_numblock, on_itblock



42
43
44
# File 'lib/rubocop/cop/sorbet/mixin/signature_help.rb', line 42

def on_block(node)
  on_signature(node) if signature?(node)
end

#on_signature(_node) ⇒ Object



49
50
51
# File 'lib/rubocop/cop/sorbet/mixin/signature_help.rb', line 49

def on_signature(_node)
  # To be defined by cop class as needed
end

#sig_with_runtime?(node) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/rubocop/cop/sorbet/mixin/signature_help.rb', line 25

def_node_matcher(:sig_with_runtime?, "(block (send\n  (const (const {nil? cbase} :T) :Sig)\n  :sig\n  (sym :final)?\n) (args) ...)\n")

#sig_without_runtime?(node) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/rubocop/cop/sorbet/mixin/signature_help.rb', line 34

def_node_matcher(:sig_without_runtime?, "(block (send\n  (const (const (const {nil? cbase} :T) :Sig) :WithoutRuntime)\n  :sig\n  (sym :final)?\n) (args) ...)\n")

#signature?(node) ⇒ Object



11
12
13
# File 'lib/rubocop/cop/sorbet/mixin/signature_help.rb', line 11

def_node_matcher(:signature?, "{#bare_sig? #sig_with_runtime? #sig_without_runtime?}\n")