Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix #832] Mark some Rails cops as unsafe autocorrection
Fixes #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')) ```
- Loading branch information