How is line code counted?

I have a 5M LoC licence and now, my sonar is full.
I don’t understand why because when i make a sum for all my projects, i got around 3M.
How is counted lines ? where can i find a report about my line usage (get the details of the 5M used) ?

Hi Cyrille,

What is used for licensing purposes is the metric “Lines Of Code”. See the description of this metric at the bottom of this page: Server Logs & System Info | SonarQube Docs 1.

If you want to re-compute the total LOCs currently consumed, you should look at all your projects scanned on SQ and take the biggest branch of each project and this will match what you see in Administration > Configuration > License Manager .

Please make sure that you have excluded third-party libs, and files that are not needed to be analyzed to reduce your license consumption.

Hope this helps,

Thanks for reply
Get inside every project and every branch can be very long and boring. Is there a way to get this information on a report or API ? Can we have the dashboard able to get the max value for line code instead of the default branch (seams we have teams that didn’t put code in master and work in a developper branch) ?

Hi @Cyrille
There is a way to query SonarQube’s API to this kind of information
To do so, you have to access the WebAPI section below the (?) menu.


There is a tool from the community that can help you achieve what you are trying to do.
Follow the link below :

Please note that this is a community tool that is not supported nor endorsed by SonarSource S.A.

You should be able to query the branches per project to get a closer count from your SonarQube’s projects.

Thanks !

thanks for the tools, but seems it’s bugged when i try to get LoC count for branches (always the same number : loc counted on master).
is there a way to get the count on the database ?