Why this matters
Misplaced blocking work causes ANRs, thread starvation, and throughput collapse.
Run blocking I/O and CPU-intensive work inside withContext(Dispatchers.IO) or Dispatchers.Default respectively. Never block the main thread.
Misplaced blocking work causes ANRs, thread starvation, and throughput collapse.
Side-by-side examples engineers can pattern-match during review.
suspend fun read(): String = File("/tmp/x").readText() // runs on caller contextsuspend fun read(): String = withContext(Dispatchers.IO) { File("/tmp/x").readText() }runBlocking { heavyBlocking() } // on mainwithContext(Dispatchers.IO) { heavyBlocking() }From the same buckets as this rule.