Hi! I’m trying to use `ForbiddenMethodCall` on a f...
# detekt
m
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
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
Adding Companion worked! Thank you