Improve Kotlin code conventions

For Kotlin tests, conventions allow using underscores, but the sonar regex is ^[a-zA-Z][a-zA-Z0-9]*$

Is there a way to add my own conventions?

Hey @JavierSC

Welcome to the Community!

The RegEx that is used by rules like this can be overridden by creating a new Quality Profile and adjusting the rule activation.

And, I’ll ping a Kotlin expert internally to see if there’s anything we should change about our default behavior.

Hey @JavierSC

I wanted to provide you with another update.

Currently – our Kotlin analyzer is not designed to analyze test sources, only main sources (controlled by what values are passed to the analysis parameters sonar.sources and sonar.tests).
While it’s possible to index all code as main sources (and therefore run all rules), it’s not recommended as you may not get super relevant analysis results (as you’ve experienced).

Analyzing test code is something we’ve started to work on for other languages, and if/when it makes its way to Kotlin, there will be a more precise rule available.

In the meantime, however, keeping the aforementioned warning in mind, you are free to adjust the regex of the existing rule.