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

Michael Marshall

02/11/2023, 7:27 AM
Hi! I’m trying to use
ForbiddenMethodCall
on a function annotated with
@JvmStatic
and it doesn’t appear in my Detekt warnings (I am running it with type resolution via
detektMain
). Is that a limitation or am I doing something wrong? detekt.yml
Copy code
ForbiddenMethodCall:
    active: true
    methods: [
      ... // Other method definitions which are working properly
      'com.bluelinelabs.conductor.RouterTransaction.with', // Not working
    ]
Function definition (from a 3rd party lib)
Copy code
package com.bluelinelabs.conductor

RouterTransaction {
...
  companion object {
    @JvmStatic
    fun with(controller: Controller): RouterTransaction = RouterTransaction(controller)
  }
}
Callsite
Copy code
RouterTransaction.with(MyController())
Using
'com.bluelinelabs.conductor.RouterTransaction.with(com.bluelinelabs.conductor.Controller)'
also doesn’t work 😕
b

Brais Gabin

02/11/2023, 9:03 AM
Maybe adding
.Companion.
I'm not sure if jvmStatic affects. You could try it with a class that you control and see what happens
m

Michael Marshall

02/11/2023, 1:50 PM
Adding Companion worked! Thank you
15 Views