# Lines of Code

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](https://www.sonarsource.com/plans-and-pricing/) page for more details.

## LOC definition <a href="#calculating-lines-of-code" id="calculating-lines-of-code"></a>

Your instance’s LOC is calculated by adding up the LOC of each project analyzed. In the case of a Data Center Edition, the LOC from each 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 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).

{% hint style="info" %}
Lines of code found in an A*pplication* do not count against your LOC. This is because Applications aggregate code from projects, and we already count the LOC once for the "parent" *project*.
{% endhint %}

## Checking your LOC consumption <a href="#checking-your-lines-of-code-consumption" id="checking-your-lines-of-code-consumption"></a>

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.

<figure><img src="https://2744305742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VWSqvZ4eaBLWvA6epdv%2Fuploads%2FKGPEOCVBH40mLSoz3p8R%2Fadmin-license-usage.png?alt=media&#x26;token=49f24a7a-812b-4f35-8dbb-45a91232e3ce" alt="Lines of code displayed on the SonarQube license page"><figcaption></figcaption></figure>

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

* Go to *Your project* > **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.
* Go to *Your Project* > **Measures** > **Size** > **Lines of Code** for a list of files and folders with a LOC count for each one.
* Go to *Your Project* > **Code** page for a list of files and folders with a LOC count for each one.&#x20;

{% hint style="info" %}
The LOC is a metric (`ncloc`) you can retrieve through the [web-api](https://docs.sonarsource.com/sonarqube-server/extension-guide/web-api "mention") by using the `/api/measures` endpoint.
{% endhint %}

## If you exceed your LOC threshold <a href="#exceeding-your-loc-threshold" id="exceeding-your-loc-threshold"></a>

Once you are near your limit, you will receive a notification. 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.
