-
Notifications
You must be signed in to change notification settings - Fork 1.7k
invariant_booleans false positive with while #57535
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
Comments
This is a known limitation of the rule. We thought it was too expensive to look for all places that modify involved variables. If |
It seems to me (based on research that's been done in this area) that it's better to have no false positives and a weak rule, then work toward making the rule catch more and more issues, than to have a rule that catches 150% of the real problems. False positives cause people to disable lints, and nothing triggers them to re-enable them later. I think that if a condition includes a reference to any non-local variable or any function (including getters and local functions) that we should assume that we don't know what the truth value of the expression will be. Also note that state mutation can be difficult to detect because the state might be far removed from the object causing it to change. |
Here's a related case that should be simple to detect, as the variable in the "invariant" condition is directly mutated inside the I did a little investigating and realized the lint correctly detects that the variable changes if it's mutated within the |
We've deprecated |
await nextPage()
updatescurrentPage
, therefore this will eventually evaluate totrue
The text was updated successfully, but these errors were encountered: