Start Free
Latest | Server upgrade and maintenance | Monitoring | Lines of Code

Monitoring your Lines of Code consumption

On this page

In SonarQube Server, the number of Lines of Code (LOC) you intend to analyze plays an important role in your choice of commercial edition (Developer, Enterprise, or Data Center). See the Sonar Plans and Pricing page for more details. 

LOC definition

Your instance's LOC is calculated by adding up the LOC of each private project analyzed. In the case of a Data Center Edition, the LOC from each private project in each cluster node is summed up. 

To calculate the LOC of a project, SonarQube Server counts the lines of code found on the most recent analysis of the largest branch or pull request of the project by excluding:  

  • Test code.
  • Files excluded from analysis.
  • Code in unsupported languages.
  • Comments or blank lines.

Example: Your instance has two private projects:

  • Project1 has 500 lines of code on its main branch and 400 on a secondary long-lived branch: its LOC is 500.
  • Project2 has 0 lines of code on its main branch (provisioned but never analyzed) and 200 on a secondary long-lived branch: its LOC is 200.
  • The total LOC for the organization is 500 + 200 = 700.

Note that you can’t use up your license by reanalyzing the same code (with the same number of lines).

Checking your LOC consumption

Go to Administration > Configuration > License Manager to check how many lines of code you are currently using. Select Edit notification threshold to define when an email should be sent with information in regards to the impending lines of code limit. You cannot exceed your LOC threshold. If you're near your limit, you may need to purchase additional lines of code. 

Lines of Code

You can check your LOC per project, per branch, in three different locations:

  • Select Project Information to reveal the LOC on your main branch (for that project). Note that this may not exactly be your max LOC, for example, another branch or PR might have more lines of code.
  • Navigate to the Your Project > Measures > Size page via the UI for a list of folders & files with a count of each folders’ and files’ LOC.
  • Navigate to Your Project > Code page for a list of folders & files with a count of each folders’ and files’ LOC.

If you exceed your LOC threshold

Once you are near your limit, you will receive a notification with advice to upgrade your current edition to a higher edition or to reduce the LOC in your projects. On the License Manager page, select the Edit notification threshold button to define when notifications will be sent.

If you reach your limit, you will receive an error message and the SonarQube Server instance will reject any analysis whose total lines of code exceed the limit defined by your license. In no way does this affect access to basic functionalities such as saving configuration changes and allowing project browsing. In all cases, you can still analyze your code if the new analysis doesn't surpass the LOC limit defined by your license.


Was this page helpful?

© 2008-2024 SonarSource SA. All rights reserved. SONAR, SONARSOURCE, SONARQUBE, and CLEAN AS YOU CODE are trademarks of SonarSource SA.

Creative Commons License