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

Recognize rails/web-console debug calls in Lint/Debugger #7296

Merged
merged 1 commit into from Dec 31, 2019
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.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