Skip to content

discarded_futures lint giving false positives #59318

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

Closed
mcmah309 opened this issue Oct 9, 2023 · 3 comments
Closed

discarded_futures lint giving false positives #59318

mcmah309 opened this issue Oct 9, 2023 · 3 comments
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. linter-false-positive P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@mcmah309
Copy link

mcmah309 commented Oct 9, 2023

Describe the issue

discarded_futures giving false positives when the future is used as a class argument.

To Reproduce

  Future<int> f(){
    return Future.value(1);
  }

  Arg g(){
    return Arg(f()); // Shows Error here
  }

  Future<void> h() async {
    await g().arg; // but the future is awaited here
  }

class Arg{
  Arg(this.arg);

  Future<int> arg;
}

But this is fine

Future<int> f(){
    return Future.value(1);
  }

  Future<int> g(){
    return f();
  }

  Future<void> h() async {
    await g();
  }

Expected behavior
The lint should only happen if the future value is not awaited, returned, or passed as an argument.

@mcmah309 mcmah309 changed the title unawaited_futures giving false positives discarded_futures lint giving false positives Oct 9, 2023
@srawlins
Copy link
Member

srawlins commented Oct 9, 2023

CC @pq I don't really understand this rule; I cannot tell if this is a false positive or expected.

@srawlins srawlins added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) P3 A lower priority bug or feature request labels Oct 17, 2023
@devoncarew devoncarew added devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Nov 20, 2024
@devoncarew devoncarew transferred this issue from dart-archive/linter Nov 20, 2024
@FMorschel
Copy link
Contributor

I think this is the same as #59151? Can someone confirm?

@srawlins
Copy link
Member

srawlins commented Jan 8, 2025

I think that's right; thanks @FMorschel

Duplicate of #59151

@srawlins srawlins closed this as completed Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. linter-false-positive P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants