Comment percentage ratio of Kotlin source code is wrong

Hi SonarQube,
We upgraded our sonarqube enterprise edition to 9.2.4 and since then the metric for the comment percentage ratio of Kotlin source code is wrong. Almost all of the files in our project are reported as having 0% comments. The newest Sonarqube version 9.3 is also affected by this issue. The impact is that the projects do not pass the Sonar Quality Gateway and we get constant alerts.

As far as I know there is no other solution than downgrading to the latest LTS version (8.9.4).

I think it is important to know and understand that only the LTS versions of Sonar are stable and reasonably bug free. This is what I learned in years of experience with Sonar.

Could please help us with this? Should we downgrade to 8.9.4 LTS or Is there any way to fix this in the current version 9.2.4?

Hi,

Welcome to the community!

To be clear, you have a Quality Gate condition requiring a certain percentage of comments on overall code? If so, would you mind sharing why?

Looking at our Kotlin analysis code in our dogfooding instance of SonarQube, I’m not seeing this problem replicated. However, what I do notice is that no comment lines are counted for the file header. I supposed you have comment lines interspersed with code that you’re not seeing counted?

Edit: Also, could you share your analysis log?

 
HTH,
Ann

Thanks Ann for your valuable inputs. :slightly_smiling_face:

Hello,

We have a similar problem since our upgrade last week. Does this screens help?

Thanks!

I did a test and it seems that we had to use a simple asterisk /* and not a double /** to begin the comments. I think that this is a mistake because, officially, Kotlin is written like JavaDoc (Document Kotlin code: KDoc and Dokka | Kotlin).

Hey @Benjamin_Bauduin,

We got similar feedback only a few days ago from one of our customers. It seems we did a mistake in our implementation of the comment measurer when we rewrote the Kotlin plugin, a few months ago.

We will fix it for our next release of the Koltin Analyzer. The sprint is however not yet planned, so I can’t tell that it will be shipped with SQ 9.4.

I created the following ticket to align it with what is done by the java measurer: SONARKT-203

Cheers,
Michael

1 Like

Hi,

It’s better now but we are not at the same level as we were before because the analyzer does not count comments on Class. Is it something wanted?

Thank you!

I just made a test and it’s ok with a simple asterisk :

1 Like