Skip to content

A broader version of unawaited_future lint for tests #57604

Open
@mehmetf

Description

@mehmetf

We already have this lint that warns you about unawaited futures if you marked your method async. I propose a broader version of this that looks that warns about unuawaited futures without caring about the async tag. It would only apply to tests because it is very rare for a developer to write test code calling async functions where they do not want to wait for the result:

   test('tests something', () {
      var myObj = new MyObj();
      myObj.doSomething(); // It happens to be async
      expect(myObj.someState, 'good');
    });

This code looks perfectly fine and raises no linter alarms. What they meant to write is:

   test('tests something', () async {
      var myObj = new MyObj();
      await myObj.doSomething();
      expect(myObj.someState, 'good');
    });

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packagetype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions