class RuboCop::Cop::Sorbet::AllowIncompatibleOverride
sig.override
# good
sig.override(allow_incompatible: true)
# bad
@example
from occurring.
subtype of its superclass. This Cop prevents these design smells
Substitution Principle, meaning that a subclass is not a valid
Using ‘allow_incompatible` suggests a violation of the Liskov
Disallows using `.override(allow_incompatible: true)`.
def on_block(node)
def on_block(node) return unless sig?(node.send_node) block = node.children.last return unless block&.send_type? receiver = block.receiver while receiver allow_incompatible_pair = override?(receiver) if allow_incompatible_pair add_offense(allow_incompatible_pair) break end receiver = receiver.receiver end end
def on_send(node)
def on_send(node) sig_dot_override?(node) do |allow_incompatible_pair| add_offense(allow_incompatible_pair) end end