Sha256: 87afb527b5129a8be9584fedb13f1590478fe8acbd4a9f3eaa0bd907d379dcf6
Contents?: true
Size: 789 Bytes
Versions: 6775
Compression:
Stored size: 789 Bytes
Contents
# frozen_string_literal: true module RuboCop module Cop module Style # This cop checks for uses of Proc.new where Kernel#proc # would be more appropriate. # # @example # # bad # p = Proc.new { |n| puts n } # # # good # p = proc { |n| puts n } # class Proc < Cop MSG = 'Use `proc` instead of `Proc.new`.'.freeze def_node_matcher :proc_new?, '(block $(send (const nil? :Proc) :new) ...)' def on_block(node) proc_new?(node) do |block_method| add_offense(block_method) end end def autocorrect(node) ->(corrector) { corrector.replace(node.source_range, 'proc') } end end end end end
Version data entries
6,775 entries across 6,769 versions & 24 rubygems