Sha256: d02a40340508957d2b0f742a8893e53467006176c23bf3202cd90bb5e66992f8

Contents?: true

Size: 493 Bytes

Versions: 3

Compression:

Stored size: 493 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    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.line, MSG)
        end

        super
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubocop-0.8.3 lib/rubocop/cop/proc.rb
rubocop-0.8.2 lib/rubocop/cop/proc.rb
rubocop-0.8.1 lib/rubocop/cop/proc.rb