Skip to content

Commit

Permalink
Recognize rails/web-console calls in Lint/Debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
gsamokovarov committed Dec 31, 2019
1 parent 38edc06 commit 958dfff
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,7 @@

### New features

* [#7296](https://github.com/rubocop-hq/rubocop/issues/7296): Recognize `console` and `binding.console` ([rails/web-console](https://github.com/rails/web-console)) calls in `Lint/Debuggers`. ([@gsamokovarov][])
* [#7567](https://github.com/rubocop-hq/rubocop/pull/7567): Introduce new `pending` status for new cops. ([@Darhazer][], [@pirj][])

### Bug fixes
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/lint/debugger.rb
Expand Up @@ -43,9 +43,9 @@ class Debugger < Cop
PATTERN

def_node_matcher :debugger_call?, <<~PATTERN
{(send {nil? #kernel?} {:debugger :byebug :remote_byebug} ...)
{(send {nil? #kernel?} {:debugger :byebug :remote_byebug :console} ...)
(send (send {#kernel? nil?} :binding)
{:pry :remote_pry :pry_remote} ...)
{:pry :remote_pry :pry_remote :console} ...)
(send (const {nil? (cbase)} :Pry) :rescue ...)
(send nil? {:save_and_open_page
:save_and_open_screenshot
Expand Down
6 changes: 5 additions & 1 deletion spec/rubocop/cop/lint/debugger_spec.rb
Expand Up @@ -50,7 +50,10 @@
include_examples 'debugger',
'capybara debug method with an argument',
'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
expect_no_offenses('binding.pirate')
Expand All @@ -59,12 +62,13 @@
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')
end

ALL_COMMANDS = %w[debugger byebug pry remote_pry pry_remote irb
ALL_COMMANDS = %w[debugger byebug console pry remote_pry pry_remote irb
save_and_open_page save_and_open_screenshot
save_screenshot remote_byebug].freeze

Expand Down

0 comments on commit 958dfff

Please sign in to comment.