forked from rubocop/rubocop
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes rubocop#7928. This PR fixes a false message for `Style/GuardClause` when using `and` or `or` operators for guard clause in `then` or `else` branches. The following is an example: ```console % cat example.rb if cond foo || raise('hi') else bar end ``` ## Before ```console % bundle exec rubocop --only Style/GuardClause (snip) Offenses: example.rb:1:1: C: Style/GuardClause: Use a guard clause (raise('hi') if cond) instead of wrapping the code inside a conditional expression. if cond ^^ 1 file inspected, 1 offense detected ``` ## After ```console % bundle exec rubocop --only Style/GuardClause (snip) Offenses: example.rb:1:1: C: Style/GuardClause: Use a guard clause (foo || raise('hi') if cond) instead of wrapping the code inside a conditional expression. if cond ^^ 1 file inspected, 1 offense detected ```
- Loading branch information
Showing
4 changed files
with
87 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
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