Method: RuboCop::Cop::Lint::NestedMethodDefinition#on_def
- Defined in:
- lib/rubocop/cop/lint/nested_method_definition.rb
#on_def(node) ⇒ Object Also known as: on_defs
97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/rubocop/cop/lint/nested_method_definition.rb', line 97 def on_def(node) subject, = *node # rubocop:disable InternalAffairs/NodeDestructuring return if node.defs_type? && allowed_subject_type?(subject) def_ancestor = node.each_ancestor(:any_def).first return unless def_ancestor within_scoping_def = node.each_ancestor(:any_block, :sclass).any? do |ancestor| scoping_method_call?(ancestor) end add_offense(node) if def_ancestor && !within_scoping_def end |