https://kotlinlang.org logo
#detekt
Title
# detekt
k

Kirill Zhukov

03/28/2023, 7:38 AM
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

Sam

03/28/2023, 7:41 AM
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

Kirill Zhukov

03/28/2023, 7:44 AM
I am running
detektMetadataCommonMain
in the kmp project, does that enable type resolution?
a

Atul Gupta

03/28/2023, 8:33 AM
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

Kirill Zhukov

03/29/2023, 2:08 AM
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

mkrussel

03/29/2023, 12:30 PM
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.
13 Views