Sonarqube 7.9.4 Difference in LOC projects and license

We have 3 projects in SQ with, according to the projects page, 415.3k LOC. The license page claims it is 488,303 so the big question is where dit those 73k LOC go?
We did recently upgrade from 7.4 where exclusions were not working and the first analysis on 7.4 dropped by like 68k LOC on one project.

So the question is how are we going to get SQ in line and fix its rather wrong LOC allocation. Is this actually by branch? Can I run a global command on the server or do I need to run an analysis on every single branch and pull request? If so, where can I find an overview of the amount of recorded LOC per branch? Because we have 170 (!) branches and PR’s in just one project and I really do not want to do that manually for every single branch.


Welcome to the community!

The Projects page shows you the LOC of the main branch of each project. The license page is pulling the LOC of the largest branch of each project.

There’s a feature request in the backlog to make this more visible. Feel free to watch/vote. In the meantime, the workaround is going to be to use the APIs to pull the long-lived branches in a project, and then iterate over them to pull the ncloc for each to find the largest ones.


Hi Ann,

To be honest I think that feature should have been a requirement for your licensing model.

But what you are saying is I should code something to pull data out of some api. I see the list of branches in the project, but when I search for loc or nloc I get no results so I am still at a loss where to go from there.

Also, is running an analysis in the build on every branch the only solutions?

  • Mark

Hi Mark,

You indicated that analysis of a project after upgrade dropped a significant number of LOC because your exclusions kicked in. There’s no other way than analysis to get those exclusions to kick in on each branch, so unfortunately, you may indeed need to do some analyses.

Regarding the API. if you look at the api/measures/component web service with “Show Internal API” enabled, you’ll see a branch parameter that you can use to pull metrics for specific branches.


Hi Ann,

When I do this
I get the loc that matches the project overview.

On this I sometimes get an empty measures result and at other times I get a much lower number. For example: [{“metric”:“ncloc”,“value”:“4646”}]
while the main branch comes in at 200k. Does this mean this branch has a diff of 4646 compared to the main branch? I do wonder why that number is empty at times.

Regards, Mark

Hi Mark,

For the very small LOC counts, I suspect this is about branch type, and that you’re looking at short-lived branches where I guess you’re only seeing a diff count. For the ones that are empty… can you double-check the interface and see if what you’re pulling from the API is matched in the UI?