Skip to content

Enable unnecessary_async and unawaited_futures lint rules #642

@cbenhagen

Description

@cbenhagen

Lint Rules to Enable

We currently have two important lint rules disabled in our analysis_options.yaml:

# TODO: Enable unnecessary_async and unawaited_futures rules
unnecessary_async: false

What these lints do

unawaited_futures

This lint warns when a Future is not awaited within an async function body. This helps prevent bugs where:

  • A function is called that returns a Future, but the result is accidentally ignored
  • Errors in the Future are silently dropped rather than properly handled
  • Functions that should complete before moving on actually run in parallel

When you genuinely want to fire-and-forget a Future, you should explicitly mark it with unawaited() from dart:async.

unnecessary_async

This lint flags functions that are marked as async but don't contain any await expressions. These functions can be simplified to synchronous functions, which:

  • Run faster (avoiding async machinery overhead)
  • Are easier to reason about
  • Allow calling code to avoid unnecessary await expressions

Action Required

We should review the codebase and carefully evaluate all instances where:

  1. Futures are not being awaited
  2. Functions are unnecessarily marked as async

We need to make deliberate decisions about how to handle each case, such as:

  • Adding proper await statements
  • Explicitly marking intentionally unawaited futures with unawaited()
  • Removing unnecessary async keywords

Once this review is complete, we can enable these rules in analysis_options.yaml to prevent similar issues in the future."

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions