Skip to content
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

False negative quick-fix trigger for unnecessary_parentheses #56699

Open
FMorschel opened this issue Sep 10, 2024 · 1 comment · May be fixed by #56746
Open

False negative quick-fix trigger for unnecessary_parentheses #56699

FMorschel opened this issue Sep 10, 2024 · 1 comment · May be fixed by #56746
Labels
analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@FMorschel
Copy link
Contributor

FMorschel commented Sep 10, 2024

False negative quick-fix trigger for unnecessary_parentheses.

Line 4 and 6 don't trigger the quick-fix but do trigger the lint. See the following code:

bool foo() {
  if ((true)) {} // <-- triggers `Unnecessary parentheses` quick fix
  final list = <(int?, int?)>[]
    ..removeWhere((r) => (r.$1 == null) && ((r.$2 == null)));
  final list2 =<int?>[] // Just so `Remove unused local variable` doesn't trigger together
    ..removeWhere((e) => ((e == null))); 
  return (true); // <-- triggers `Unnecessary parentheses` quick fix
}

bool baz(int? i) => (i == null); // <-- triggers `Unnecessary parentheses` quick fix
@dart-github-bot
Copy link
Collaborator

Summary: The unnecessary_parentheses quick-fix incorrectly fails to trigger in certain cases, such as when parentheses are used around a conditional expression within a removeWhere method call. This results in a false negative for the quick-fix.

@dart-github-bot dart-github-bot added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Sep 10, 2024
@pq pq added analyzer-quick-fix P2 A bug or feature request we're likely to work on and removed triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. labels Sep 10, 2024
@FMorschel FMorschel linked a pull request Sep 18, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants