Sha256: 5409553706463774e1997abb8db6d4ee1b30a927010161d60a11339621e5bd65
Contents?: true
Size: 1.38 KB
Versions: 12
Compression:
Stored size: 1.38 KB
Contents
# encoding: utf-8 # frozen_string_literal: true module RuboCop module Cop module Lint # This cop checks for calls to debugger or pry. class Debugger < Cop MSG = 'Remove debugger entry point `%s`.'.freeze def_node_matcher :debugger_call?, <<-END {(send nil {:debugger :byebug} ...) (send (send nil :binding) {:pry :remote_pry :pry_remote} ...) (send (const nil :Pry) :rescue ...) (send nil {:save_and_open_page :save_and_open_screenshot :save_screenshot} ...)} END def_node_matcher :pry_rescue?, '(send (const nil :Pry) :rescue ...)' def on_send(node) return unless debugger_call?(node) add_offense(node, :expression, format(MSG, node.source)) end def autocorrect(node) lambda do |corrector| if pry_rescue?(node) block = node.parent body = block.children[2] # (block <send> <parameters> <body>) corrector.replace(block.source_range, body.source) else range = node.source_range range = range_with_surrounding_space(range, :left, false) range = range_with_surrounding_space(range, :right, true) corrector.remove(range) end end end end end end end
Version data entries
12 entries across 12 versions & 2 rubygems