class RuboCop::Cop::Sorbet::AllowIncompatibleOverride
This cop disallows using `.override(allow_incompatible: true)`. Using `allow_incompatible` suggests a violation of the Liskov Substitution Principle, meaning that a subclass is not a valid subtype of it's superclass. This Cop
prevents these design smells from occurring.
@example
# bad sig.override(allow_incompatible: true) # good sig.override
Public Instance Methods
not_nil?(node)
click to toggle source
# File lib/rubocop/cop/sorbet/signatures/allow_incompatible_override.rb, line 31 def not_nil?(node) !node.nil? end
on_send(node)
click to toggle source
# File lib/rubocop/cop/sorbet/signatures/allow_incompatible_override.rb, line 48 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