LoC not counted correctly in SonarQube

Last month we extended our license from 250k to 500k lines of code.

Surprisingly we received today a notification that we are reaching limit of LoC (around 450k used).

But when we count a Lines of Code in current Projects it is something around 300k LoC. It is possible that this is a bug? Is there any suitable way to get the count of LoC that we are paying for ?

Hey there.

SonarQube takes into consideration the largest branch of each project. Have you checked the individual branches of each project?

Hello Colin,

Thank you for your reply.

I went through our Projects and It seems that when I summarize largest branches in each project there is totally around 300k LoC.

Br,
Marcin

Thanks @Marcin_J

What version are you using? There is an API endpoint in the latest version, GET api/projects/license_usage, that should help instance administrators understand the LoC and branch being counted for each project.

Hi Colin,
Unfortunately we’ve version: * Developer Edition

  • Version 9.3 (build 51899)

In that case, I recommend upgrading to a supported version (v9.7)

Hello Colin, I found other way to count LoC. I setup python script squtilities/locbyproject.py at master · alexandre-frigout-sonarsource/squtilities · GitHub

Indeed count of LoC is much different than visible in Portal – “Total number of lines of code in your SonarQube instance: 447790”

I can see now that if Main Branch is not analyzed the LoC count is not visible:


But is counted as well in License. Would be nice to have on the list counted branch visible (because this was analyzed in SonarQube).

image

It is implemented in newest version of SonarQube ?

Thank you for your help

Br
Marcin

Hi @Marcin_J,

You won’t find a change regarding that point in the latest version. The information displayed in the projects list relates only to the main branch in order to avoid bringing confusion.
Also, please tell me if you have another perspective on the topic, but I think that in many cases the number of lines of code on the main branch is a good approximation. I’d be happy to understand why your main branch is not displayed, apart from the fact the project is quite new.

Chris