"Findbugs" for kotlin?

Hi,

Is there a static analisys tool for kotlin? It would be just great, especially with maven and IDEA integration.

2 Likes

Yes, it would be nice to have such a tool. To my knowledge, it is not there yet. Note that many of the issues found by FindBugs are impossible in Kotlin. Those that are possible would be nice to find automatically, you are right

what about checkstyle, PMD, sonarqube and all of our other good old friends?! IMHO if kotlin states to be an enterprise replacement for java, it should offer at least one sophisticated option as soon as (or somewhen right after) it goes stable. are there any plans, collaborations with other communities?

There's nothing definite so far, but we are open to proposals.

Remember that IntelliJ itself comes with a rather powerful static analysis engine called the Inspector. I used to play with FindBugs a lot, but eventually settled on just using the Inspector, as it runs in the background and has good editor / intention integration. The number of issues it can find is rather good, so if I was the boss of the Kotlin team (ha ha) I'd prioritise porting of the Inspector over FindBugs. Of course this helps sales of IDEA as well :)

And if that wasn’t enough then after Inspector I’d prioritise a version of the Checker Framework, as its philosophy of pragmatic type system extensions with annotations aligns quite well with Kotlin’s.

2 Likes

I'm a big fan of the IntelliJ Inspections, too. I consider them much better than PMD and Findbugs. Good Kotlin inspections would be another good argument to use this language.

The problem with just using IntelliJ for static analysis is that I can’t use it in my CI server or even from the command line. I agree with christoph.pickl that there needs to be equivalent tools for kotlin if it is to be a serious replacement for Java

IntelliJ can be used in headless mode with build servers, too.

1 Like

https://www.jetbrains.com/help/idea/2016.1/running-inspections-offline.html
https://confluence.jetbrains.com/display/TCD9/Inspections

2 Likes

I’ve always avoided installing IDEs on servers (even in the .net world, where it’s not so uncommon installing VS on CI server). So a standalone version of the static analysis tool we have in IDEA would be really appreciated…

6 Likes

The question was asked long time ago. However, in 2020 I am using detekt library for detecting a bug as well. Detekt tool is purely built in Kotlin and purely designed for Kotlin and used for various purposes to improve code quality. Here is good article about it. Detecting Kotlin Code Smells with Detekt | by Mario Sanoguera de Lorenzo | ProAndroidDev

1 Like