diff --git a/changelog/new_make_lint_debugger_aware_of_debug_rb.md b/changelog/new_make_lint_debugger_aware_of_debug_rb.md new file mode 100644 index 00000000000..3b9fea54e0b --- /dev/null +++ b/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][]) diff --git a/config/default.yml b/config/default.yml index 7bf7514ba4a..0d0c8e03ec8 100644 --- a/config/default.yml +++ b/config/default.yml @@ -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 diff --git a/lib/rubocop/cop/lint/debugger.rb b/lib/rubocop/cop/lint/debugger.rb index 9f6b0697e23..68bd4573fd0 100644 --- a/lib/rubocop/cop/lint/debugger.rb +++ b/lib/rubocop/cop/lint/debugger.rb @@ -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: # diff --git a/spec/rubocop/cop/lint/debugger_spec.rb b/spec/rubocop/cop/lint/debugger_spec.rb index 33fa76afeea..debd54d4ab2 100644 --- a/spec/rubocop/cop/lint/debugger_spec.rb +++ b/spec/rubocop/cop/lint/debugger_spec.rb @@ -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)