class RuboCop::Cop::Sorbet::AllowIncompatibleOverride
sig.override
# good
sig.override(allow_incompatible: true)
# bad
@example
from occurring.
subtype of it’s 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
This cop disallows using `.override(allow_incompatible: true)`.
def not_nil?(node)
def not_nil?(node) !node.nil? end
def on_send(node)
def on_send(node) return unless allow_incompatible_override?(node) add_offense( node.children[2], message: "Usage of `allow_incompatible` suggests a violation of the Liskov Substitution Principle. "\ "Instead, strive to write interfaces which respect subtyping principles and remove `allow_incompatible`", ) end