async { } is awaited right away, so nothing runs concurrently with it

tx0/kotlin:async-awaited-at-oncerecommendedwarningreliability/concurrencydepth fastsmell, concurrency

What it finds

async { work() }.await() starts a coroutine and waits for it on the spot. Nothing runs alongside it, so it only adds a coroutine; withContext switches the context when that is what the async was for, and otherwise the work can be called directly.

From the rule's source, async_await_at_once.rs.

Example from the rule's tests
suspend fun load(scope: CoroutineScope): Int {    val a = scope.async { fetch() }.await()tx0 reports: the async coroutine is awaited at once    val b = scope.async { fetch() }    val c = scope.async { fetch() }    return a + b.await() + c.await()}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/kotlin:async-awaited-at-once" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/kotlin:async-awaited-at-once] reason="..."

tx0 explain tx0/kotlin:async-awaited-at-once shows the same in the terminal. Found a false positive? Report it.