Discrepancy between Sonar Cloud Organisation LOC and sum of all project LOCs

Hi Team, I require help in understanding two things as an admin of sonar cloud in my organisation:

  • I calculated the aggregate sum of all nloc values of all projects in an organisation but it is less compared to the consumed lines as per data in admin panel. For instance, my org limit is 2.7M and it shows 2.63M is consumed but the sum of nlocs I fetched using api is 2.3M. Why is this difference?
  • I couldn’t find any api that can directly fetch the consumed LOC, don’t we have that yet? (just wanted to setup an alert system for my team when we hit more than 90% of the limit)

Please someone help me to get clarity on these two.

Hi,

Welcome to the community!

Licensing counts the LOC from the largest branch or PR in each project. When you did your data collection, did you check each branch of each project, or only the main branch?

 
Ann

Hi Ann,
I have used this api to get nloc of each project in my org and added them which is giving me 2.3M which is different from what I see at lines consumed org administration level. Doesn’t the nloc metric cover up all the lines consumed in project?

Hi,

That API accepts a branch parameter. Did you call it for each branch in each project to find the LOC of the largest branch per project?

 
Ann