Sha256: 781efc6b5a19138385a9d4ee4fa550da87a3d1d383825c31e1bb4a7d75a82d7a

Contents?: true

Size: 1.31 KB

Versions: 8

Compression:

Stored size: 1.31 KB

Contents

# encoding: utf-8

module RuboCop
  module Cop
    module Lint
      # This cop checks for calls to debugger or pry.
      class Debugger < Cop
        MSG = 'Remove debugger entry point `%s`.'

        # debugger call node
        #
        # (send nil :debugger)
        DEBUGGER_NODE = s(:send, nil, :debugger)

        # byebug call node
        #
        # (send nil :byebug)
        BYEBUG_NODE = s(:send, nil, :byebug)

        # binding.pry node
        #
        # (send
        #   (send nil :binding) :pry)
        PRY_NODE = s(:send, s(:send, nil, :binding), :pry)

        # binding.remote_pry node
        #
        # (send
        #   (send nil :binding) :remote_pry)
        REMOTE_PRY_NODE = s(:send, s(:send, nil, :binding), :remote_pry)

        # binding.pry_remote node
        #
        # (send
        #   (send nil :binding) :pry_remote)
        PRY_REMOTE_NODE = s(:send, s(:send, nil, :binding), :pry_remote)

        DEBUGGER_NODES = [
          DEBUGGER_NODE,
          BYEBUG_NODE,
          PRY_NODE,
          REMOTE_PRY_NODE,
          PRY_REMOTE_NODE
        ]

        def on_send(node)
          return unless DEBUGGER_NODES.include?(node)
          add_offense(node,
                      :expression,
                      format(MSG, node.loc.expression.source))
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/lib/rubocop/cop/lint/debugger.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/lib/rubocop/cop/lint/debugger.rb
rubocop-0.28.0 lib/rubocop/cop/lint/debugger.rb
rubocop-0.27.1 lib/rubocop/cop/lint/debugger.rb
rubocop-0.27.0 lib/rubocop/cop/lint/debugger.rb
rubocop-0.26.1 lib/rubocop/cop/lint/debugger.rb
rubocop-0.26.0 lib/rubocop/cop/lint/debugger.rb
rubocop-0.25.0 lib/rubocop/cop/lint/debugger.rb