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

Ólavur Joensen

06/04/2019, 2:14 PM
Hi, I am experiencing some trouble running Detekt on one of our Kotlin (JVM) projects through Gradle. I have it configured in Gradle/Groovy with a basic
Copy code
detekt {
    toolVersion = "1.0.0-RC14"
    input = files("src/main/kotlin")
    filters = ".*/resources/.*,.*/build/.*"
}
I get loads of errors in the console, all with the following message:
Copy code
Analyzing '[filename redacted]' led to an exception.
The original exception message was: java.lang.NoClassDefFoundError: io/gitlab/arturbosch/detekt/rules/LinesOfCodeKt$tokenSequence$1
Running detekt '1.0.0-RC14' on Java '1.8.0_151-b12' on OS 'Mac OS X'.
(am running Gradle 5.4.1) What I’ve tried - Building and running Detekt via the CLI - this works fine, and gives me a report (I ran it on the same project that fails via the Gradle). - Switching to version 1.0.0-RC13 via Gradle yields the same errors as with RC14 - Clearing out the gradle caches and
gradle clean
does not seem to have any effect - (edit) Running the gradle task inside a Docker container using
gradle@latest
image doesn’t help Ideally, I want it to be run via Gradle - does anyone have any pointers as to what may the cause of this issue, or perhaps how I can fix it?
m

Mike

06/04/2019, 2:33 PM
What version of the Gradle plugin are you using? I suspect a mis-match there
ó

Ólavur Joensen

06/04/2019, 3:43 PM
id "io.gitlab.arturbosch.detekt" version "1.0.0-RC14"
Just tried to run
gradle detekt
inside a Docker container using the
gradle@latest
image - that oddly gave me the same series of
NoClassDefFoundError
s

schalkms

06/04/2019, 9:04 PM
Have you tried running it on a just one example file? Have you tried using a more recent Java version? I mean
LinesOfCode
is no rule. That's interesting.
ó

Ólavur Joensen

06/05/2019, 7:31 AM
Just tried by updating Java, but unfortunately no success.
LinesOfCode
is not a rule, but it does exist: https://github.com/arturbosch/detekt/blob/master/detekt-rules/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/LinesOfCode.kt The odd thing is that if I dig into the detekt-rules JAR in the Gradle cache, the class seems to be there.
s

schalkms

06/05/2019, 6:10 PM
@Ólavur Joensen could you please create an issue on GitHub so that we can track your problem? Please include your settings, used versions and most importantly your Gradle build script. This helps us to narrow down the problem. Thank you.
ó

Ólavur Joensen

06/06/2019, 1:44 PM
Will do! 🙂
s

schalkms

06/07/2019, 2:42 PM
Thank you! 🙂
a

Artur Bosch

06/08/2019, 8:03 AM
Interesting the lines of code feature makes use of kotlin generators which sometimes feel a bit buggy in IntelliJ (can't debugging). What is your Kotlin version? Maybe your version and detekt's version somehow mismatch. detekt runs and needs 1.3.* for these
sequence
builders
ó

Ólavur Joensen

06/14/2019, 2:13 PM
@Artur Bosch does that mean that my project has to use kotlin 1.3.+ in order for detekt to work?
s

schalkms

06/14/2019, 5:06 PM
@Ólavur Joensen Nope. It's only needed for detekt itself.
ó

Ólavur Joensen

06/14/2019, 5:11 PM
@schalkms Yea, I would expect that to be the case - thanks for verifying. My project is a Spring project, so maybe the Spring gradle plugin is interfering with the classpath. I am in the process of devising a minimal project that reproduces the problem, and will post that build.gradle in an Issue :)
s

schalkms

06/14/2019, 7:52 PM
Interesting.. Please keep us posted.
ó

Ólavur Joensen

08/12/2019, 8:47 AM
@schalkms @Artur Bosch Just wanted to inform you that this issue seems to be resolved with the release of 1.0.0. I never quite figured out why this went wrong, but detekt runs smoothly on our projects now 🙂
s

schalkms

08/12/2019, 7:14 PM
Good! That's nice to hear!
14 Views