Sha256: 5f74e466f04039dd9d5fdd8772fc134a5e85395cb5ff80fe1dff07e7099a82d9

Contents?: true

Size: 655 Bytes

Versions: 3

Compression:

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

          super
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
rubocop-0.9.1 lib/rubocop/cop/style/proc.rb
sabat-rubocop-0.9.0 lib/rubocop/cop/style/proc.rb
rubocop-0.9.0 lib/rubocop/cop/style/proc.rb