This came up in a Google-internal discussion as something that some people like to write and would hate the linter to drop the parentheses for them.
As such, it's a blocker for internal adoption.
I would like to introduce these rules:
(a ? b : c) is always OK
(a == b) and (a != b) are OK in assignment-like and return-like statements.
Examples of replacements that I wish didn't happen (copying my own comments from that discussion):
-
Foo(String? name) : name = (name == null || name.isEmpty ? _generateNodeName() : name),
Foo(String? name) : name = name == null || name.isEmpty ? _generateNodeName() : name,
This is a downgrade because my mind jumps to read it as (name = name == null || the rest).
-
node.hasValue = (value == null);
node.hasValue = value == null;
I dislike the fact that Value = value jumps out at me so strongly. Part of it might just be an issue of distance because == is just longer and makes the precedence appear lower than =. The other part is that I want to use the parentheses to stress the fact that I'm assigning the result of a boolean expression, not assigning "value with some other code trailing behind it".
I will immediately open a pull request that would address this issue.
This came up in a Google-internal discussion as something that some people like to write and would hate the linter to drop the parentheses for them.
As such, it's a blocker for internal adoption.
I would like to introduce these rules:
(a ? b : c)is always OK(a == b)and(a != b)are OK in assignment-like and return-like statements.Examples of replacements that I wish didn't happen (copying my own comments from that discussion):
This is a downgrade because my mind jumps to read it as
(name = name == null || the rest).I dislike the fact that
Value = valuejumps out at me so strongly. Part of it might just be an issue of distance because==is just longer and makes the precedence appear lower than=. The other part is that I want to use the parentheses to stress the fact that I'm assigning the result of a boolean expression, not assigning "value with some other code trailing behind it".I will immediately open a pull request that would address this issue.