Sha256: 0b86a3c09357f8aa5d41cbed8e662d62a6b840dcb4e127887fe43949e804201c
Contents?: true
Size: 800 Bytes
Versions: 38
Compression:
Stored size: 800 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 < Base extend AutoCorrector MSG = 'Use `proc` instead of `Proc.new`.' # @!method proc_new?(node) def_node_matcher :proc_new?, '(block $(send (const {nil? cbase} :Proc) :new) ...)' def on_block(node) proc_new?(node) do |block_method| add_offense(block_method) do |corrector| corrector.replace(block_method, 'proc') end end end end end end end
Version data entries
38 entries across 38 versions & 6 rubygems