bbaldino
07/08/2020, 5:23 PMForbiddenMethodCall
to work, I've got it configured like so:
style:
active: true
ForbiddenMethodCall:
active: true
methods: ['java.util.concurrent.ExecutorService.submit', 'kotlin.io.println']
in a custom detekt.yml
(which doesn't contain much else). I'm using the maven plugin and have it pointing to that config file. (I added println
in there to try and test after the first one wasn't working.) It's not triggering for println
calls or ExecutorService.submit
calls. I tried adding another rule and that did work...so maybe I've just got something misconfigured for ForbiddenMethodCall
?gammax
07/08/2020, 5:25 PMbbaldino
07/08/2020, 5:26 PMgammax
07/08/2020, 5:28 PMForbiddenMethodClass
uses symbol resolution (that is experimental). To enable it you need to create a custom detektMain
task and provide classpath
and `jvmTarget`: https://detekt.github.io/detekt/groovydsl.html#using-type-resolutionbbaldino
07/08/2020, 5:29 PMgammax
07/08/2020, 5:39 PMbbaldino
07/08/2020, 5:40 PMgammax
07/08/2020, 5:40 PMbbaldino
07/08/2020, 5:40 PMgammax
07/08/2020, 5:40 PMthis isn’t on android...just normal jvm.oops my bad, you’re right.
bbaldino
07/08/2020, 5:42 PM${java.class.path}
, but I see lots of complaints about kotlin stdlib in detekt outputgammax
07/08/2020, 5:42 PMbbaldino
07/08/2020, 5:42 PMExecutorService#submit
there and it did catch it...so I think it's just a matter of the classpath not including the kotlin stdlib?gammax
07/08/2020, 5:47 PMbbaldino
07/08/2020, 5:48 PM/Vp8UtilsTest.kt:56:32: error: cannot access built-in declaration '<http://kotlin.Int|kotlin.Int>'. Ensure that you have a dependency on the Kotlin standard library
gammax
07/08/2020, 5:54 PMbbaldino
07/08/2020, 5:55 PMmvn dependency:build-classpath
and hard-coding that into the classPath
field in the config for the maven plugin (it gives a string like /Users/bbaldino/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.72/kotlin-stdlib-jdk8-1.3.72.jar:...
), but I get complaints about warning: classpath entry points to a non-existent location
...I dunno if that's from some sandboxing or something.kotlin-stdlib-1.3.72.jar
into the project directory and do <classPath>${java.class.path};${project.basedir}/kotlin-stdlib-1.3.72.jar</classPath>
that does appear to work...