Hi, I am experiencing some trouble running Detekt ...
# detekt
ó
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
What version of the Gradle plugin are you using? I suspect a mis-match there
ó
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
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.
ó
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
@Ó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.
ó
Will do! 🙂
s
Thank you! 🙂
a
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
ó
@Artur Bosch does that mean that my project has to use kotlin 1.3.+ in order for detekt to work?
s
@Ólavur Joensen Nope. It's only needed for detekt itself.
ó
@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
Interesting.. Please keep us posted.
ó
@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
Good! That's nice to hear!