class RuboCop::Cop::Lint::NestedMethodDefinition

def on_def(node)

def on_def(node)
  subject, = *node
  return if node.defs_type? && subject.lvar_type?
  def_ancestor = node.each_ancestor(:def, :defs).first
  return unless def_ancestor
  within_scoping_def =
    node.each_ancestor(:block, :numblock, :sclass).any? do |ancestor|
      scoping_method_call?(ancestor)
    end
  add_offense(node) if def_ancestor && !within_scoping_def
end