Thread.sleep() inside a suspend function
Part of Code Quality & Syntax, which counts for 20% of the overall score. When this check fires it deducts 8 points from that category, once per scan, no matter how many places it turns up.
What it detects
Thread.sleep() inside a suspend function blocks the underlying worker thread for the sleep's duration instead of suspending the coroutine, defeating the point of using coroutines and potentially starving a limited dispatcher. kotlinx.coroutines.delay() suspends without blocking the thread. Function-scoped detection (brace-matched to the suspend fun body), so this is tighter than a file-level co-occurrence heuristic.
Why it matters
Thread.sleep() inside a suspend function blocks the underlying worker thread for the sleep's full duration instead of suspending the coroutine, which defeats the entire point of using coroutines: the thread cannot be handed back to run other coroutines in the meantime. On a limited dispatcher (Dispatchers.Main, or any fixed-size thread pool) this can starve unrelated work waiting for a free thread. This is a well-known, frequently made mistake for anyone new to Kotlin coroutines coming from thread-based concurrency.
How to fix it
Replace Thread.sleep(millis) with kotlinx.coroutines.delay(millis) (suspend fun delay), which suspends the coroutine without blocking its underlying thread, freeing that thread to run other coroutines until the delay elapses.
The paid report includes a ready-to-paste prompt for your AI coding agent for every check it finds, pointed at the exact findings from your scan. See pricing
Does your repo trip this check?
Paste a GitHub URL or drop a project folder. Scans run in your browser and take seconds.
Scan your repo