-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Update: Check for default assignment in no-unneeded-ternary (fixes #3232) #3260
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
Conversation
Will this warn for constructs like But then again that isn't always the same as |
It only handles |
I think we need to handle more than identifiers for this option. Really, anything to the left of |
That's not necessarily true if the thing in question has side effects. I think it might be safe to add a few other expression types ( |
@cjihrig Even bare identifiers can have side effects if the references cannot be statically resolved. We have to draw the line somewhere. I think identifiers and static member access is enough. |
FYI: If we would flag all matches, this can be used. |
We kind of left this hanging. Thoughts on how to resolve? Also, I think the option |
I picked |
I don't have any better ideas, so maybe we do |
Got rid of the double negative. |
Update: Check for default assignment in no-unneeded-ternary (fixes #3232)
Add ability to check for
x ? x : y
pattern, which can be rewritten asx || y
. AddsnoDefaultAssignment
option tono-unneeded-ternary
rule. Defaults to off for backwards compatibility. Closes #3232.