Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Lint/Debugger aware of debug.rb #10040

Merged
merged 1 commit into from Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/new_make_lint_debugger_aware_of_debug_rb.md
@@ -0,0 +1 @@
* [#10040](https://github.com/rubocop/rubocop/pull/10040): Make `Lint/Debugger` aware of debug.rb. ([@koic][])
5 changes: 5 additions & 0 deletions config/default.yml
Expand Up @@ -1519,6 +1519,11 @@ Lint/Debugger:
Capybara:
- save_and_open_page
- save_and_open_screenshot
debug.rb:
- binding.b
- binding.break
- Kernel.binding.b
- Kernel.binding.break
Pry:
- binding.pry
- binding.remote_pry
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/lint/debugger.rb
Expand Up @@ -7,8 +7,8 @@ module Lint
# not be kept for production code.
#
# The cop can be configured using `DebuggerMethods`. By default, a number of gems
# debug entrypoints are configured (`Kernel`, `Byebug`, `Capybara`, `Pry`, `Rails`,
# `RubyJard` and `WebConsole`). Additional methods can be added.
# debug entrypoints are configured (`Kernel`, `Byebug`, `Capybara`, `debug.rb`,
# `Pry`, `Rails`, `RubyJard`, and `WebConsole`). Additional methods can be added.
#
# Specific default groups can be disabled if necessary:
#
Expand Down
30 changes: 30 additions & 0 deletions spec/rubocop/cop/lint/debugger_spec.rb
Expand Up @@ -114,6 +114,36 @@
end
end

context 'debug.rb' do
it 'registers an offense for a `b` binding call' do
expect_offense(<<~RUBY)
binding.b
^^^^^^^^^ Remove debugger entry point `binding.b`.
RUBY
end

it 'registers an offense for a `break` binding call' do
expect_offense(<<~RUBY)
binding.break
^^^^^^^^^^^^^ Remove debugger entry point `binding.break`.
RUBY
end

it 'registers an offense for a `binding.b` with `Kernel` call' do
expect_offense(<<~RUBY)
Kernel.binding.b
^^^^^^^^^^^^^^^^ Remove debugger entry point `Kernel.binding.b`.
RUBY
end

it 'registers an offense for a `binding.break` with `Kernel` call' do
expect_offense(<<~RUBY)
Kernel.binding.break
^^^^^^^^^^^^^^^^^^^^ Remove debugger entry point `Kernel.binding.break`.
RUBY
end
end

context 'pry' do
it 'registers an offense for a pry binding call' do
expect_offense(<<~RUBY)
Expand Down