Class: RuboCop::Cop::Sorbet::ForbidSigWithoutRuntime

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

Overview

Check that ‘sig` is used instead of `T::Sig::WithoutRuntime.sig`.

Good:

“‘ sig { void } def foo; end “`

Bad:

“‘ T::Sig::WithoutRuntime.sig { void } def foo; end “`

Constant Summary collapse

MSG =
"Do not use `T::Sig::WithoutRuntime.sig`."

Instance Method Summary collapse

Methods included from SignatureHelp

#bare_sig?, #on_block, #sig_with_runtime?, #sig_without_runtime?, #signature?

Instance Method Details

#on_signature(node) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/rubocop/cop/sorbet/signatures/forbid_sig_without_runtime.rb', line 29

def on_signature(node)
  return unless sig_without_runtime?(node)

  sig = node.children[0]
  add_offense(sig) do |corrector|
    corrector.replace(sig, sig.source.gsub(/T\s*::\s*Sig\s*::\s*WithoutRuntime\s*\.\s*/m, ""))
  end
end