Skip to content

discarded_futures generates warnings on waitFor #58852

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
bsutton opened this issue Sep 1, 2022 · 2 comments
Closed

discarded_futures generates warnings on waitFor #58852

bsutton opened this issue Sep 1, 2022 · 2 comments
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead.

Comments

@bsutton
Copy link

bsutton commented Sep 1, 2022

I'm the deveveloper of DCli which is an SDK for developing dart console apps.
https://onepub.dev/packages/dcli

DCli is a heavy user of waitFor (although we always us it wrapped in our own function waitForEx).

The new lint discarded_futures (which I'm very pleased to see has been released in 2.18) is however causing some problems in DCli code.

The purpose of the waitFor and waitForEx functions is to convert an async all to a sync call.

T waitFor(Future future, {Duration? timeout}) ;

T waitForEx(Future future)

Globally disabling the future isn't acceptable as it is a critical lint in CLI programming.
A forgotten await can result in you accidentally deleting the entire contents of your hard drive.

Is there some way to disable the lint at the declaration site rather than at each call site?
e.g.

// ignore_calls: discarded_futures
T waitForEx<T>(Future<T> future) {
{
}

rather than:

String resolveSymLink(String pathToLink) =>
            // ignore: discarded_futures
    waitForEx(core.resolveSymLink(pathToLink));
@pq
Copy link
Member

pq commented Sep 6, 2022

See also: #46218

@srawlins
Copy link
Member

Yeah I'd say follow along at #46218

@devoncarew devoncarew added devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Nov 19, 2024
@devoncarew devoncarew transferred this issue from dart-archive/linter Nov 19, 2024
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.
Projects
None yet
Development

No branches or pull requests

4 participants