Sonar custom plugin rule - kotlin

What are you trying to accomplish?
I have a custom sonar rule for java which scans all java files and identifies something as per my requirement. Now I have a requirement to implement same custom rule but it should scan all kotlin files. More details below.

I need to apply this new sonar rule to all projects (some projects are written in java and some in kotlin).

I have implemented the plugin for java classes, want to implement same functionality for kotlin classes as well.

Query -

  1. Can i use sonar-kotlin-plugin (group: ‘org.sonarsource.kotlin’, name: ‘sonar-kotlin-plugin’) to achieve this?
  2. Do i need to write my custom plugin code in kotlin language or can write in java language ?

any documentation for usage of kotlin api would really help.


As noted in your other thread, there’s no direct support for custom Kotlin rules. Your best bet is to run your check before analysis and output the generic issue format.