forked from rubocop/rubocop-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes rubocop#116 and adds regression tests for rubocop#115. This PR fixes an incorrect autocorrect for `Rails/Presence` when `else` branch of ternary operator is not nil. The following is a reproduction procedure. ```ruby # example.rb a.blank? ? 1 : a ``` ```console % bundle exec rubocop --only Rails/Presence -a Inspecting 1 file C Offenses: example.rb:1:1: C: [Corrected] Rails/Presence: Use a.presence instead of a.blank? ? 1 : a. a.blank? ? 1 : a ^^^^^^^^^^^^^^^^ 1 file inspected, 1 offense detected, 1 offense corrected ``` ```diff -a.blank? ? 1 : a +a.presence ``` This PR will auto-correct it to `a.presence || 1`.
- Loading branch information
Showing
3 changed files
with
6 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters