A suspend function calls nothing, so it can never suspend

tx0/kotlin:suspend-without-callsrecommendedwarningreliability/concurrencydepth fastsmell, concurrency

What it finds

suspend lets a function call other suspending functions. A function that calls nothing at all never suspends, and the modifier only forces its callers into a coroutine. Overrides, open and abstract members, members of interfaces, and expect or actual declarations are left out, as their signature is given elsewhere. Reading coroutineContext counts as suspending.

From the rule's source, suspend_without_suspension.rs.

Example from the rule's tests
class Repository(private val items: List<Int>) {    suspend fun size(): Int {tx0 reports: size is suspend but calls nothing that could suspend        return 42    }     suspend fun first(): Int = load()     override suspend fun count(): Int = 3     suspend fun drain(channel: ReceiveChannel<Int>) {        for (item in channel) {}    }}
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:suspend-without-calls" = "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:suspend-without-calls] reason="..."

tx0 explain tx0/kotlin:suspend-without-calls shows the same in the terminal. Found a false positive? Report it.