Sha256: 66b9e0de1f1adc0f9973939a8dfac9aa1b0cc0e578b93fea7b7e04dbbbfbc1e6

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 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)

        DEBUGGER_NODES = [
          DEBUGGER_NODE,
          BYEBUG_NODE,
          PRY_NODE,
          REMOTE_PRY_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

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-0.22.0 lib/rubocop/cop/lint/debugger.rb