Skip to content

Commit 487463c

Browse files
committed
[Fix rubocop#832] Mark some Rails cops as unsafe autocorrection
Fixes rubocop#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')) ```
1 parent 41a5571 commit 487463c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

config/default.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ Rails/ActionControllerFlashBeforeRender:
7373
StyleGuide: 'https://rails.rubystyle.guide/#flash-before-render'
7474
Reference: 'https://api.rubyonrails.org/classes/ActionController/FlashBeforeRender.html'
7575
Enabled: 'pending'
76-
SafeAutocorrect: false
76+
SafeAutoCorrect: false
7777
VersionAdded: '2.16'
7878

7979
Rails/ActionControllerTestCase:
8080
Description: 'Use `ActionDispatch::IntegrationTest` instead of `ActionController::TestCase`.'
8181
StyleGuide: 'https://rails.rubystyle.guide/#integration-testing'
8282
Reference: 'https://api.rubyonrails.org/classes/ActionController/TestCase.html'
8383
Enabled: 'pending'
84-
SafeAutocorrect: false
84+
SafeAutoCorrect: false
8585
VersionAdded: '2.14'
8686
Include:
8787
- '**/test/**/*.rb'
@@ -873,7 +873,7 @@ Rails/RootJoinChain:
873873
Rails/RootPathnameMethods:
874874
Description: 'Use `Rails.root` IO methods instead of passing it to `File`.'
875875
Enabled: pending
876-
SafeAutocorrect: false
876+
SafeAutoCorrect: false
877877
VersionAdded: '2.16'
878878

879879
Rails/RootPublicPath:

0 commit comments

Comments
 (0)