SonarQube 9.2 - Mismatch on LOC

Hi,

We’re running SonarQube 9.2.2.xxx at our company and on a annual licenses checkup, we found out that the LOC mentioned by the license manager does not match the sum of all projects´s LOC.

On the license manager it shows that we’ve ~11M LOC and if we query each projects nloc via API we get a total of ~15M LOC.

Here’s the API endpoint that we’ve used:
/api/measures/component?component={component}&branch={branch}&metricKeys=ncloc

On this query, we loop through every project and respective branches.

Do you know why this mismatch?

Thank you,

Hello Ruben,

Welcome to the Community Forum.

The license manager will only account for the largest branch in each project. Is it possible that your query is accounting for every single branch?

Hi Luís,

Thank you for your help!
Yes, my query is getting every branch of every project.

The largest branch LOC is the one that you see under the project information?

image

Regards,

Hi Ruben,

Typically yes, but there can be cases where the main branch is not the largest. For billing LOC count purposes, the largest branch is the one accounted for.

Hmm, that’s weird! If I query only the main branches (the LOC that appear on the project information page), I only get ~4M LOC.

API query used:
/api/measures/component?component={component}&metricKeys=ncloc

It seems that some of the branches are not being taking in consideration for licensing purposes. Do you know if there’s some sort of “expiration” date? For example, if a branch is not analyzed for more than X days it stops impacting the licensing.