Does anyone have problems getting all of these Cor...
# detekt
Does anyone have problems getting all of these Coroutine rules to run? Only the Globalscope one seems to run in our project (gradle and custom detekt.yml) but I have all of them enabled 🤔 Also tested using the CLI version of Detekt and the --all-rules parameter but that doesn't even show the GlobalScope violation.
I threw all the sample incorrect code into a file to test:
Copy code
// test a few detekt warnings
suspend fun detektWarningMess() {
    GlobalScope.launch {
        withContext(Dispatchers.Unconfined) {

suspend fun unneededSecondSuspend() {

suspend fun CoroutineScope.unneededExtensionSuspend() {
    launch {

suspend fun unneededSuspendFlow(): Flow<Unit> {
    val pollingInterval = 123L
    return flow {
        while (true) {
Also added --debug to the CLI version of detekt and it claims the coroutines ruleset is loaded 🤔
Copy code
Registered rule sets:
hmmm...maybe this: The rule 'InjectDispatcher' requires type resolution but it was run without it.
Not obvious...detekt should probably put up a BIG warning when rules are run w/o type resolution in the gradle plugin.
Hmm...even when you run detektMain or detektDebug, only the InjectDispatcher rule works out of the ones that are listed are requiring type resolution 🤔
The IDE flags all of them though...just that CI won't
FYI, this works when running the gradle task on detektDebug for me (all rules show up).
That's strange...
Enabling type resolution should work
Sorry it did...was just a running log of all the things I tried to get to the end state. We missed the type configuration configuration and didn't notice it was needed for the new rules when upgrading Detekt a while back.
Some more "in your face" warning when rules are enabled but skipped because type resolution isn't used would probably be a good idea..
Hmm..ok..maybe not. It's inconsistent. Sometimes the InjectDispatcher rule runs, sometimes it doesn't when I run the detektDebug task. EDIT: build cache issue....detekt results apparently go into the remote build cache so it only reruns if the code changes.
one more thing that was unexpected is if you run a different detekt<variant> task, the filename for the report changes. CI was looking for detekt.xml but if you run the detektDebug task, the report is named "debug.xml" instead...
A lot of things here. The information about "this rule has not been executed" was there. But it was reported as far too much noise so we removed it... It is difficult to make happy to everyone :(
If you see flaky results, please open an issue with a way to reproduce them. That should not happen.
And yes, the reports have different name because if you run
it will execute it for debug and for release. And you don't want to get only one of those reports. You want both. So, for that reason, they should have different names.
yep, makes sense. I was just documenting in the thread in case anyone searches for this 🙂
Disappointed folks didn't like the "rule was not executed" warning though 🤦‍♂️ Just disable it in detekt.yml then... 😂