Skip to content

unnecessary_parenthesis sometimes not reported for doubled parentheses #58952

Closed
dart-archive/linter
#3887
@oprypin

Description

@oprypin

Some examples of what it currently misses but should lint:

Int64((12 * 60 * 60))   // ArgumentList(BinaryExpression)

`a.compareTo((b.bar))`  // ArgumentList(MethodInvocation)

foo.addAll((await fut)) // ArgumentList(AwaitExpression)

`'${(foo == bar.baz)}'  // InterpolationExpression(BinaryExpression)

So I would like to introduce a rule that

  • ${( )} and (( )) are never OK, drop the inner ones.

It's just that it's a bit tricky to find in the language what exactly constitutes these doubled parentheses. For example:

  • ArgumentList with length of 1 is always an extra set of parentheses
    (which already covers almost all bad cases for this issue).
  • So is an if statement, but somehow I can't trigger any false negative with it.

I will immediately open a pull request that would address this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestdevexp-linterIssues with the analyzer's support for the linter packagelegacy-area-analyzerUse area-devexp instead.linter-false-negativeIssues related to lint rules that fail to report a problem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions