The part of our codebase which is using Kotlin is getting bigger and bigger. And apart from the fact that the coding rules supplied by the SonarKotlin plugin is pretty basic, we have a need for custom coding rules (specific to our coding rules & architecture).
Unfortunately custom coding rules for Kotlin seems not to be officially supported. But using the Slang project I was able to build a dummy custom rule using the language agnostic AST. But as it’s language agnostic it’s very limited.
I saw that the Kotlin plugin itself uses org.jetbrains.kotlin.psi.* API. Is there any way to access the Kotlin PsiElements somehow?
Sorry for such a late reply. Currently we do not support custom rules and do not expose Kotlin Psi in Kotlin plugin. But we will keep that in mind for our future work in Kotlin plugin.
First of all, you can propose your rule ideas and we’ll probably investigate whether we can implement them in the plugin itself. You can also try custom rules in Detekt or AndroidLint and we’re going to import them as external issues.