class RuboCop::Cop::Style::MissingRespondToMissing
end
# …
def method_missing(name, *args)
end
# …
def respond_to_missing?(name, include_private)
#good
end
# …
def method_missing(name, *args)
#bad
@example
defining ‘respond_to_missing?`.
This cop checks for the presence of `method_missing` without also
def implements_respond_to_missing?(node)
def implements_respond_to_missing?(node) node.parent.each_child_node(node.type).any? do |sibling| sibling.method?(:respond_to_missing?) end end
def on_def(node)
def on_def(node) return unless node.method?(:method_missing) return if implements_respond_to_missing?(node) add_offense(node) end