Sha256: 57cbf78415e669dd77dc93ef08d929396eafe051b2a37a813f45cc6f976f6f94

Contents?: true

Size: 638 Bytes

Versions: 4

Compression:

Stored size: 638 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

          if block_method == TARGET
            add_offence(:convention, block_method.loc.expression, MSG)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.12.0 lib/rubocop/cop/style/proc.rb
rubocop-0.11.1 lib/rubocop/cop/style/proc.rb
rubocop-0.11.0 lib/rubocop/cop/style/proc.rb
rubocop-0.10.0 lib/rubocop/cop/style/proc.rb