Get the licence LOC breakdown per project

Hello

we are deploying a Developer Edition of SonarQube to our development teams.

As it is a new tool introduction, we expect regular mistakes in properly narrowing down the scope analysis of projects. With probably some over consumption of our LOC licence.

An interesting “feature” would be to easily get, within the licence tab (/admin/extension/license/app), a view showing all projects and it consumed LOC.
Something like //admin/projects_management view, with licence LOC consumption.

Any thought?

On the project tab you see all analyzed projects and the project size. You can even order by size. Maybe this helps already …

Hello

thanks for your answer.

When reading https://docs.sonarqube.org/latest/instance-administration/system-info/#header-3, it says:

If you’re on a commercial edition and using Branch or PR analysis, rest assured that only lines from the single largest branch in a project are considered for licensing purposes. The Lines of Code in the rest of the branches are ignored.

From a licence management perspective, being able to know what part of a project LOC are impacting the global licence LOC would be very helpful to perform licence usage reviews.

Maybe it is possible to generate such report using API…

You can do this with the API. Use projects/search to get the list of projects, then for each project use measures/component?components=projectKey&metricKeys=ncloc.

Hello
would this API calls provide the “real” LOC number impacting the paid licence? Or should we need to loop over all analysed branches (i don’t see branch parameter in the API)
As when you perform branch analysis, only the branch with the biggest number of LOC is considered being the project LOC impacting the licence…

This code just gives you the master LOC. You can add a loop inside the for-each project to for-each branch and get the LOC for those, keeping the largest value. I run it periodically for all our projects (> 2k projects with some having >50 branches).

1 Like

All this having been said I agree that it would be helpful for Sonarqube to save the information used to generate the License LOC and provide it as a page under License management.