Is `ForbiddenMethodCall` expected to work? I have ...
# detekt
k
Is
ForbiddenMethodCall
expected to work? I have this config and it doesn’t seem to pick up on
runBlocking
calls in the codebase 👀
Copy code
ForbiddenMethodCall:
  active: true
  methods:
      value: 'runBlocking'
Other rules seem to work in the same file
also tried fq
kotlinx.coroutines.runBlocking
Even default method calls for
println
and
print
aren’t caught
s
Are you running detekt with type resolution turned on? Looks like type resolution is required for the ForbiddenMethodCall rule. https://detekt.dev/docs/gettingstarted/type-resolution
k
I am running
detektMetadataCommonMain
in the kmp project, does that enable type resolution?
a
In Gradle logs
detekt
prints if any rule is skipped due to type resolution or not Log message:
The rule 'UnnecessarySafeCall' requires type resolution but it was run without it
Put
Copy code
detekt {
    debug = true
}
in detekt gradle config
k
Yeah, that’s exactly what I’m seeing
The rule 'ForbiddenMethodCall' requires type resolution but it was run without it.
I’m a little confused by how to enable type resolution for
commonMain
source set? 🤔
m
I did some custom configuration and task building to make sure all the source sets being used by Android and JVM targets were added to the type resolution task instead of just their own. Then made sure I didn't create detekt tasks for the meta source sets. My gradle expertise is not high, so there's probably a lot wrong with this script, but it seems to accomplish what I need.