Skip to content

Commit

Permalink
Remove console from Lint/Debugger
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gsamokovarov committed Jan 7, 2020
1 parent d5334b9 commit f274609
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/lint/debugger.rb
Expand Up @@ -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 ...)
Expand Down
2 changes: 0 additions & 2 deletions spec/rubocop/cop/lint/debugger_spec.rb
Expand Up @@ -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
Expand All @@ -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')
Expand Down

0 comments on commit f274609

Please sign in to comment.