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?, <<~PATTERN)
  (block (send
    nil?
    :sig
    (sym :final)?
  ) (args) ...)
PATTERN

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



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



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

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?, <<~PATTERN)
  (block (send
    (const (const {nil? cbase} :T) :Sig)
    :sig
    (sym :final)?
  ) (args) ...)
PATTERN

#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?, <<~PATTERN)
  (block (send
    (const (const (const {nil? cbase} :T) :Sig) :WithoutRuntime)
    :sig
    (sym :final)?
  ) (args) ...)
PATTERN

#signature?(node) ⇒ Object



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

def_node_matcher(:signature?, <<~PATTERN)
  {#bare_sig? #sig_with_runtime? #sig_without_runtime?}
PATTERN