About Sonarqube license calculation


on this page : Plans & Pricing | Sonar, we can read :

How do we count Lines of Code (LOC)?

LOCs are computed by summing up the LOCs of each project analyzed. Lines of test code are never included in this number. The LOCs used for a project are the ones found during the most recent analysis of this project. If you start using the branch analysis, then the LOCs of a project will be computed from the project’s largest branch.

We have a few questions about this definition :

  • Is this “LOC” equal to sum of “ncloc” measure ? or sum of “ncloc + comment_lines” ?

  • What is the definition of “largest” here ? biggest nb of commits ? biggest ncloc ? biggest “ncloc + comment_lines” ? Something else ?

  • About “Lines of test code are never included in this number.” This is clear, but strange because according to the custom rules API, you can create a rule targetting test code (like checking the presence of “assertions” in test code).


It’s ncloc only. Which, BTW, stands for ‘non-comment lines of code’ (so no reason we’d add comments back in).

Branch / PR with the biggest ncloc count

Our :gift: to you.
But feel free to buy a bigger license than you need to make up for the test lines we’re not counting. :crazy_face:


Ok, thanks for the informations ! :slight_smile:

It’s fine like you do, don’t get greedy… :money_mouth_face:

1 Like