I’m getting a huge number of compilation errors wh...
# detekt
m
I’m getting a huge number of compilation errors when I run
./gradlew detektMain
on my Android project. Including this… 😂
Copy code
error: 'trySend(E): ChannelResult<Unit>' is only available since Kotlin 1.4.30 and cannot be used in Kotlin 1.5
These errors don’t come up when compiling normally, what’s happening here?
🤔 1
g
Which version of Kotlin are you using?
m
Our project uses Kotlin 1.5.20
g
Are you on Detekt
1.18.0
?
m
1.15.0 at the moment. I tried to use 1.18.0 but it complained about my config file being invalid at “comments>excludes” so I backtracked
I have these applied to my subprojects
Copy code
tasks.withType<Detekt> {
    jvmTarget = "11"
}
Copy code
detekt {
    toolVersion = Dependencies.Libraries.detektVersion
    input = files("src/main/java")
    config = rootProject.files("buildSrc/detekt.yml")
}
g
You would need to update to
1.18.0
to make it work correctly. The reason is that
1.15.x
was using a older version of Kotlin: https://detekt.github.io/detekt/compatibility.html#detekt-support-commitment Therefore it’s loading a older version of kotlin-compiler-embeddable and is not able to analyse your code correctly. We will do a point release soon-ish to fix the issue you’re experiencing with
"comments>excludes"
🙌 1
m
So if I understand correctly, the Kotlin version being used is determined by Detekt, not the project it’s in?
g
When you use
detektMain
, yes.
In the future we’re looking into offering this: github.com/detekt/detekt-compiler-plugin/ This will make integration with your normal compilation flow easier.
m
Ah sweet! Is Java 11 supported yet?
g
it is 👍
❤️ 1
m
Awesome, I’ll wait for the 1.18.1 release then - is there a timeline?
g
When we have time 😁
😂 2
m
Can’t argue with that
I’ve upgraded to 1.18.0 but I’m still getting compilation errors, e.g.
Copy code
error: class 'MyClass' is not abstract and does not implement abstract member public abstract fun describeContents(): Int defined in android.os.Parcelable
for a class that has
@Parcelize
and lots of
error: unresolved reference: someVar
g
That’s potentially the same issue as: https://github.com/detekt/detekt/issues/3272
m
Yep it sounds a lot like what it quotes in there:
This is due to the inability to gather the complete compile classpath from the Android Gradle Plugin (upstream ticket) and can safely be ignored.
I’ll just wait for the Kotlin compiler plugin and ignore the errors for now
g
Yes so you’ll probably see those compilation error, but Detekt will run regardless (with some unresolved symbols).
m
It might be nice to have that on the documentation somewhere, since it really looks like something’s gone wrong when you run it