Sha256: 5d5aa6810fbf6945374faf4f92255160c23395711960db07763a25661e2401cb
Contents?: true
Size: 589 Bytes
Versions: 106
Compression:
Stored size: 589 Bytes
Contents
# frozen_string_literal: true module CustomCops # This cop checks for dynamically defining methods # # @example # #bad # Foo.define_method(:bar) { p 'bar } # # #good # #create the method on the object # class Foo # def self.bar # puts 'bar' # end # end # class DefineMethod < RuboCop::Cop::Cop MSG = 'Avoid define_method.' def_node_matcher :defining_method?, '(send _ :define_method ...)' def on_send(node) return unless defining_method?(node) add_offense(node, location: :selector) end end end
Version data entries
106 entries across 106 versions & 1 rubygems