Sha256: 9f7336fa169b355d03f6657baee2121567a7042138d10c7e1d8628a48f62e3c1

Contents?: true

Size: 591 Bytes

Versions: 5

Compression:

Stored size: 591 Bytes

Contents

# encoding: utf-8

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.'

        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

          convention(block_method, :expression) if block_method == TARGET
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubocop-0.15.0 lib/rubocop/cop/style/proc.rb
rubocop-0.14.1 lib/rubocop/cop/style/proc.rb
rubocop-0.14.0 lib/rubocop/cop/style/proc.rb
rubocop-0.13.1 lib/rubocop/cop/style/proc.rb
rubocop-0.13.0 lib/rubocop/cop/style/proc.rb