Sha256: 616d9e3ef9dd083dbd6720424a3872c4d972846ac858e5ad213851c46f3a2574
Contents?: true
Size: 816 Bytes
Versions: 8
Compression:
Stored size: 816 Bytes
Contents
# encoding: utf-8 module RuboCop module Cop module Lint # This cop checks for nested method definitions. # # @example # # `bar` definition actually produces methods in the same scope # # as the outer `foo` method. Furthermore, the `bar` method # # will be redefined every time the `foo` is invoked # def foo # def bar # end # end # class NestedMethodDefinition < Cop include OnMethodDef MSG = 'Method definitions must not be nested. ' \ 'Use `lambda` instead.' def on_method_def(node, _method_name, _args, _body) node.each_descendant(:def) do |nested_def_node| add_offense(nested_def_node, :expression) end end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems