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.
A fairly common mistake with Rails is to enqueue a job from inside a
transaction, with a record as argumemnt, which then lead to a RecordNotFound
error when picked up by the queue.
This is even one of the arguments advanced for job runners backed by the
database such as `solid_queue`, `delayed_job` or `good_job`.
But relying on this is undesirable in my opinion as it makes the Active Job
abstraction leaky, and if in the future you need to migrate to another backend
or even just move the queue to a separate database, you may experience a lot of
race conditions of the sort.
To resolve this problem globally, we can make Active Job optionally transaction
aware, and automatically defer job queueing to `after_commit`.
Co-Authored-By: Cristian Bica <cristian.bica@gmail.com>
This pull request enables `Minitest/NonExecutableTestMethod` cop
to find non-executed test that is out of `ActiveSupport::TestCase` and its subclasses.
This cop is based on the request since there was a test that is not executed found
at https://github.com/rails/rails/pull/50334#issuecomment-1851411434
and implemented to RuboCop Minitest 0.34.0 via https://github.com/rubocop/rubocop-minitest/issues/279
This cop works as follows.
As of right now, there is no offenses by reverting the merge commit via #50334
```
$ git revert -m 1 9517841
$ bundle exec rubocop
Inspecting 3254 files
... snip ...
Offenses:
activerecord/test/cases/assertions/query_assertions_test.rb:27:5: W: Minitest/NonExecutableTestMethod: Test method should be defined inside a test class to ensure execution.
def test_assert_no_queries ...
^^^^^^^^^^^^^^^^^^^^^^^^^^
3254 files inspected, 1 offense detected
$
```
* `Gemfile.lock` has been updated as follows
```
bundle update rubocop rubocop-minitest --conservative
```
There are assertions that expected/actual arguments are passed in the
reversed order by mistake. Enabling the LiteralAsActualArgument rule
prevents this mistake from happening.
The existing tests were auto-corrected by rubocop with a bit of
indentation adjustment.
Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
Generated using the following script and manually reviewed after:
skipkayhil/rails-bin@cbad7eddcb
The active_storage configuration had to be moved to the dummy app
because of the changed eager_load config. Now, the whole app is eagerly
loaded when the app's environment file is required which means that
changing configuration in the test_helper is too late.
Ref: ad39d6b
Ensure that all evals include file and line number to identify their
source.
Two of the evals reported by this cop were unneccesary and replaced with
non-eval alternatives: xml is set as a local variable in
Template::Handlers::Builder#call, and instance_eval isn't needed to get
the current binding.
There are additionally 27 offenses in test directories, but since it
seems less important to fix those they are currently ignored.
* Switch to a single controller option for choosing JavaScript approach
* Remove remnants of webpacker specific work within Rails
* No longer used
* Missing space
* Raise if unknown option is passed
* Style
* Use latest versions
* Make channels setup generic to all node setups
* Make Action Text installer work with any node package manager
* Explaining variables are not useless
* Rubocop pleasing
* Don't rely on Rails.root
Tests don't like it!
* Rubocopping
* Assume importmap
* No longer relevant
* Another cop
* Style
* Correct installation notice
* Add dependencies for action cable when adding a channel
* Fix paths to be relative to generator
* Just go straight to yarn, forget about binstub
* Fix tests
* Fixup installer, only yarn once
* Test generically with run
* Style
* Fix reference and reversibility
* Style
* Fix test
* Test pinning dependencies
* Remove extra space
* Add more tests
* Use latest dependencies
* Relegated this to controllers
* Refactor ChannelGenerator + more tests
Use a uniform level of abstraction
I found an unexpected use of assertion in the block of `assert_raise`
when I implemented https://github.com/rubocop/rubocop-minitest/pull/137.
It is expected to be asserted after an exception is raised in
`assert_raise` block, but in actually it is not asserted after an
exception is raised. Therefore, this PR removes or updates assertions
that have not been asserted after an exception has raised.
This PR will add `rubocop-minitest` and enable
`Minitest/UnreachableAssertion` cop to able similar auto-detection,
but will remove `rubocop-minitest` from this PR if you don't like it.
`bind_call(obj, ...)` is a faster alternative to `bind(obj).call(...)`.
https://bugs.ruby-lang.org/issues/15955
Also, enable `Performance/BindCall` cop to detect those in the future.