Skip to content

discarded_futures generates warnings on waitFor #58852

Closed
@bsutton

Description

@bsutton

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));

Metadata

Metadata

Assignees

No one assigned

    Labels

    devexp-linterIssues with the analyzer's support for the linter packagelegacy-area-analyzerUse area-devexp instead.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions