unnecessary_parenthesis should not be so strict around cascades #57845
Labels
devexp-linter
Issues with the analyzer's support for the linter package
legacy-area-analyzer
Use area-devexp instead.
There are currently some allowances for "unnecessary" parenthesis around cascades:
This says "If the parenthesized thing is a cascade, and the parentheses are in some expression hierarchy with a cascade above them, then allow the parens."
I think this should be changed to an "or":
Here are some (simplified) examples I've seen, where this lint rule complains today, which highlight common "unnecessary" parentheses patterns, which I think we should allow:
Here the parens defensively guard against unknown cascade vs conditional (
?:
) precedence. They arguably make the code more readable, even when dartfmt helps as well with proper indentation.These parens again guard against the precedence misunderstandings with nested cascades, method calls and assignments.
Here the parens guard against precedence between the inner cascade and an outer assignment.
Rather than play more games with how to allow cascades, I propose to just allow "unnecessary" parens around any cascade, and below any cascade.
The text was updated successfully, but these errors were encountered: