You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Fixrubocop#832] Mark some Rails cops as unsafe autocorrection
Fixesrubocop#832.
This commit marks `Rails/ActionControllerFlashBeforeRender`, `Rails/ActionControllerTestCase`,
and `Rails/RootPathnameMethods` cops as unsafe autocorrection to resolve unexpected behaviors.
## Before
Behave as a safe autocorrection (`-a`).
```consle
% echo "File.open(Rails.root.join('db', 'schema.rb'))" |
bundle exec rubocop --stdin example.rb -a --enable-pending-cops --require=rubocop-rails --only Rails/RootPathnameMethods
Inspecting 1 file
C
Offenses:
example.rb:1:1: C: [Corrected] Rails/RootPathnameMethods: Rails.root is a Pathname so you can just append #open.
File.open(Rails.root.join('db', 'schema.rb'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1 file inspected, 1 offense detected, 1 offense corrected
====================
Rails.root.join('db', 'schema.rb').open
```
## After
Behave as an unsafe autocorrection (`-A`).
```console
% echo "File.open(Rails.root.join('db', 'schema.rb'))" |
bundle exec rubocop --stdin example.rb -a --enable-pending-cops --require=rubocop-rails --only Rails/RootPathnameMethods
Inspecting 1 file
C
Offenses:
example.rb:1:1: C: [Correctable] Rails/RootPathnameMethods: Rails.root is a Pathname so you can just append #open.
File.open(Rails.root.join('db', 'schema.rb'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1 file inspected, 1 offense detected, 1 more offense can be corrected with `rubocop -A`
====================
File.open(Rails.root.join('db', 'schema.rb'))
```
0 commit comments