/api/measures/component?metricKeys=ncloc,coverage sometimes doesn't return ncloc value

Must-share information (formatted with Markdown):

  • Sonarqube 7.9.1

I’m using this API
/api/measures/component?metricKeys=ncloc,coverage…&componentKey=project:filepath

to get sonarqube stats for a file so I can group the stats.
Sometimes files don’t include the ncloc parameter but return a valid coverage value.
The files this occurs on are definitely source files and not generated files.
Is this a bug?

p.s. asking for generated_ncloc return 0 for that value as expected. But ncloc is missing…
p.p.s. hmm…asking for “lines” returns a number. The file has no comments…this is probably a bug IMHO. I can use lines if ncloc is null/missing.

p.p.p.s., our internal Sonarqube supports noticed the reason why…Kotlin files w/ trailing commas aren’t supported in Sonarqube 7.9.1 :frowning:

Hi @kenyee ,

SonarQube 7.9.1 is nearly 18 months old and no longer LTS, so you need to upgrade to SonarQube 8.9 LTS at least (actually SonarQube 9.0 is going to be released very soon, early July 2021). It includes support for trailing commas in Kotlin.

So after you upgrade, test the web API again and see if you still have issues since many things have changed, improved, and secured.

Joe

Yep, we’re going to 8.9 LTS this month ironically enough :slightly_smiling_face:
Just bad timing/luck on my part :frowning:

1 Like

Thanks for the update. Yea, you’ll have to wait until the upgrade is complete to see if your issue still occurs. Please do come back to this thread and let me know your results once the upgrade is complete.