# How the LOC are getting calculated?

**URL:** <https://community.sonarsource.com/t/how-the-loc-are-getting-calculated/94694>\
**Category:** SonarQube Server / Community Build\
**Tags:** license\
**Created:** [June 26, 2023, 9:57pm UTC](https://community.sonarsource.com/t/how-the-loc-are-getting-calculated/94694 "2023-06-26T21:57:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![contrasec](https://avatars.discourse-cdn.com/v4/letter/c/958977/32.png) [@contrasec](https://community.sonarsource.com/u/contrasec)\
**Post date:** [June 26, 2023, 9:57pm UTC](https://community.sonarsource.com/t/how-the-loc-are-getting-calculated/94694/1 "2023-06-26T21:57:09Z")

</div>

Hi,  
We have a Project A with the following activities:  
Scan #1: Activity log shows some 580 LOC  
Scan #2: Activity log shows 23k LOC  
Scan #3: Again 580 LOC  
Scan #4: Again 23k LOC  
Scan #5: 580 LOC  
Now what will be calculated against the license? Will it be 23k or 500 or 23.5k?  
But on the project information it is only showing 580 which is the latest scan. We are kind of confused here and what is the exact number of LOC calculated? How can we make sure that it is correct?  
Also, we observed that our overall license consumption is getting lowered sometimes, for ex on one day it is showing 1.2M and the other day it is like 1M. Please advise.  
Thanks

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [June 27, 2023, 6:36pm UTC](https://community.sonarsource.com/t/how-the-loc-are-getting-calculated/94694/2 "2023-06-27T18:36:07Z")

</div>

Hi,

The docs have a [pretty thorough rundown](https://docs.sonarqube.org/latest/instance-administration/lines-of-code/#calculating-lines-of-code).

If you’re talking about a project with only one branch, then the LoC counted for that project will be the LoC from the most recent analysis. If there are multiple branches/PRs, it’s the LoC of the most recent analysis of the biggest branch (a PR is unlikely to be the biggest although they are checked).

&nbsp;  
HTH,  
Ann
