From f2746091bef39fe1465ad368283106e35cd63f0c Mon Sep 17 00:00:00 2001 From: Genadi Samokovarov Date: Tue, 7 Jan 2020 22:24:10 +0200 Subject: [PATCH] Remove `console` from `Lint/Debugger` It's ambiguous and we can play games and try not to recognize: ```ruby console do with_a_block end ``` But, other use cases will come up. Web Console supports `binding.console`, which is safe to recognize by a linter, so let's drop the ambiguous `console` one. --- CHANGELOG.md | 4 ++++ lib/rubocop/cop/lint/debugger.rb | 2 +- spec/rubocop/cop/lint/debugger_spec.rb | 2 -- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3dbe877be1..9aa88926e95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## master (unreleased) +### Changes + +* [#7636](https://github.com/rubocop-hq/rubocop/issues/7636): Remove `console` from `Lint/Debugger` to prevent false positives. ([@gsamokovarov][]) + ## 0.79.0 (2020-01-06) ### New features diff --git a/lib/rubocop/cop/lint/debugger.rb b/lib/rubocop/cop/lint/debugger.rb index 5d9a98f8aad..f3e95d1193e 100644 --- a/lib/rubocop/cop/lint/debugger.rb +++ b/lib/rubocop/cop/lint/debugger.rb @@ -43,7 +43,7 @@ class Debugger < Cop PATTERN def_node_matcher :debugger_call?, <<~PATTERN - {(send {nil? #kernel?} {:debugger :byebug :remote_byebug :console} ...) + {(send {nil? #kernel?} {:debugger :byebug :remote_byebug} ...) (send (send {#kernel? nil?} :binding) {:pry :remote_pry :pry_remote :console} ...) (send (const {nil? (cbase)} :Pry) :rescue ...) diff --git a/spec/rubocop/cop/lint/debugger_spec.rb b/spec/rubocop/cop/lint/debugger_spec.rb index 35812d89e4b..79cea6a4c45 100644 --- a/spec/rubocop/cop/lint/debugger_spec.rb +++ b/spec/rubocop/cop/lint/debugger_spec.rb @@ -52,7 +52,6 @@ 'save_screenshot foo' include_examples 'debugger', 'remote_byebug', 'remote_byebug' - include_examples 'debugger', 'web console', 'console' include_examples 'debugger', 'web console binding', 'binding.console' it 'does not report an offense for a non-pry binding' do @@ -62,7 +61,6 @@ include_examples 'debugger', 'debugger with Kernel', 'Kernel.debugger' include_examples 'debugger', 'debugger with ::Kernel', '::Kernel.debugger' include_examples 'debugger', 'binding.pry with Kernel', 'Kernel.binding.pry' - include_examples 'debugger', 'web console with Kernel', 'Kernel.console' it 'does not report an offense for save_and_open_page with Kernel' do expect_no_offenses('Kernel.save_and_open_page')