-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix void_function_in_ternary incorrectly triggered with if statement #5674
base: main
Are you sure you want to change the base?
Conversation
Here's an example of your CHANGELOG entry: * Fix void_function_in_ternary incorrectly triggered with if statement.
[u-abyss](https://github.com/u-abyss)
[#issue_number](https://github.com/realm/SwiftLint/issues/issue_number) note: There are two invisible spaces after the entry's text. Generated by 🚫 Danger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks taking up the issue!
The current implementation is very specific to implicit returns. However, if
and switch
expression can also appear as variable initializers and they can be nested into each other. I don't think the current solution addresses these cases, does it?
isTrue ? defaultValue() : defaultValue() | ||
} else { | ||
"Default" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This misses a return
, doesn't it?
Fixes #5611
This PR corrects that VoidFunctionInTernaryConditionRule incorrectly triggered with if statement.
This new rule is triggered or not depending on the return type of the function.