Sha256: e954f28b83922a644b17cfe93c1fab1a24c90d6afaf8acf9cfced1f9f1c7e647
Contents?: true
Size: 731 Bytes
Versions: 3
Compression:
Stored size: 731 Bytes
Contents
# frozen_string_literal: true module RuboCop module Cop module Style # This cops checks for uses of Proc.new where Kernel#proc # would be more appropriate. class Proc < Cop MSG = 'Use `proc` instead of `Proc.new`.'.freeze TARGET = s(:send, s(:const, nil, :Proc), :new) def on_block(node) # We're looking for # (block # (send # (const nil :Proc) :new) # ...) block_method, = *node add_offense(block_method, :expression) if block_method == TARGET end def autocorrect(node) ->(corrector) { corrector.replace(node.source_range, 'proc') } end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.45.0 | lib/rubocop/cop/style/proc.rb |
rubocop-0.44.1 | lib/rubocop/cop/style/proc.rb |
rubocop-0.44.0 | lib/rubocop/cop/style/proc.rb |