Enable Lint/Debugger

This will prevent issues like be0cb4e8f9, which would have resulted in:

```
guides/rails_guides/generator.rb:16:1: W: Lint/Debugger: Remove debugger entry point require "debug".
require "debug"
^^^^^^^^^^^^^^^
```

Disabled the cop in actionpack tests for screenshot_helper and page_dump_helper:

```
actionpack/test/controller/integration_test.rb:1369:9: W: Lint/Debugger: Remove debugger entry point save_and_open_page.
        save_and_open_page
        ^^^^^^^^^^^^^^^^^^
actionpack/test/controller/integration_test.rb:1381:11: W: Lint/Debugger: Remove debugger entry point save_and_open_page.
          save_and_open_page
          ^^^^^^^^^^^^^^^^^^
actionpack/test/controller/integration_test.rb:1391:39: W: Lint/Debugger: Remove debugger entry point save_and_open_page.
      assert_raise(InvalidResponse) { save_and_open_page }
                                      ^^^^^^^^^^^^^^^^^^
```

```
actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:111:13: W: Lint/Debugger: Remove debugger entry point page.save_page(absolute_html_path).
            page.save_page(absolute_html_path)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:115:13: W: Lint/Debugger: Remove debugger entry point page.save_screenshot(absolute_image
_path).
            page.save_screenshot(absolute_image_path)
```

The DebuggerRequires option was first available in rubocop v1.63.0, in rubocop/rubocop#12766.
This commit is contained in:
zzak 2024-05-13 13:37:15 +09:00
parent ad0e3123e1
commit 833c1c9a4d
No known key found for this signature in database
GPG Key ID: 213927DFCF4FF102
4 changed files with 15 additions and 6 deletions

View File

@ -223,6 +223,11 @@ Lint/AmbiguousOperator:
Lint/AmbiguousRegexpLiteral: Lint/AmbiguousRegexpLiteral:
Enabled: true Enabled: true
Lint/Debugger:
Enabled: true
DebuggerRequires:
- debug
Lint/DuplicateRequire: Lint/DuplicateRequire:
Enabled: true Enabled: true

View File

@ -371,7 +371,7 @@ GEM
racc (~> 1.4) racc (~> 1.4)
os (1.1.4) os (1.1.4)
parallel (1.24.0) parallel (1.24.0)
parser (3.2.2.4) parser (3.3.1.0)
ast (~> 2.4.1) ast (~> 2.4.1)
racc racc
path_expander (1.1.1) path_expander (1.1.1)
@ -444,19 +444,19 @@ GEM
retriable (3.1.2) retriable (3.1.2)
rexml (3.2.6) rexml (3.2.6)
rouge (4.2.0) rouge (4.2.0)
rubocop (1.59.0) rubocop (1.63.5)
json (~> 2.3) json (~> 2.3)
language_server-protocol (>= 3.17.0) language_server-protocol (>= 3.17.0)
parallel (~> 1.10) parallel (~> 1.10)
parser (>= 3.2.2.4) parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0) rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0) regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0) rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.30.0, < 2.0) rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7) ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0) unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0) rubocop-ast (1.31.3)
parser (>= 3.2.1.0) parser (>= 3.3.1.0)
rubocop-md (1.2.2) rubocop-md (1.2.2)
rubocop (>= 1.0) rubocop (>= 1.0)
rubocop-minitest (0.34.3) rubocop-minitest (0.34.3)

View File

@ -107,6 +107,7 @@ module ActionDispatch
"#{absolute_path}.html" "#{absolute_path}.html"
end end
# rubocop:disable Lint/Debugger
def save_html def save_html
page.save_page(absolute_html_path) page.save_page(absolute_html_path)
end end
@ -114,6 +115,7 @@ module ActionDispatch
def save_image def save_image
page.save_screenshot(absolute_image_path) page.save_screenshot(absolute_image_path)
end end
# rubocop:enable Lint/Debugger
def output_type def output_type
# Environment variables have priority # Environment variables have priority

View File

@ -1309,6 +1309,7 @@ class IntegrationFileUploadTest < ActionDispatch::IntegrationTest
end end
end end
# rubocop:disable Lint/Debugger
class PageDumpIntegrationTest < ActionDispatch::IntegrationTest class PageDumpIntegrationTest < ActionDispatch::IntegrationTest
class FooController < ActionController::Base class FooController < ActionController::Base
def index def index
@ -1392,3 +1393,4 @@ class PageDumpIntegrationTest < ActionDispatch::IntegrationTest
end end
end end
end end
# rubocop:enable Lint/Debugger