# LOC from Pull Request appearing license\_usage

**URL:** <https://community.sonarsource.com/t/loc-from-pull-request-appearing-license-usage/179480>\
**Category:** SonarQube Server / Community Build\
**Tags:** server, sonarqube, cli\
**Created:** [March 11, 2026, 6:33pm UTC](https://community.sonarsource.com/t/loc-from-pull-request-appearing-license-usage/179480 "2026-03-11T18:33:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eman\_Harri](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/eman_harri/32/68821_2.png) [@Eman\_Harri](https://community.sonarsource.com/u/Eman_Harri)\
**Post date:** [March 11, 2026, 6:33pm UTC](https://community.sonarsource.com/t/loc-from-pull-request-appearing-license-usage/179480/1 "2026-03-11T18:33:20Z")

</div>

Hello,

We are reviewing our SonarQube license usage using the API:

```bash
/api/projects/license_usage

```

We noticed that in some cases the **LOC reported appears to come from a Pull Request analysis instead of the active branch (with largest LOC)**.

Example scenario:

- The **first analysis for the project was a PR scan**

- The PR analysis shows **27 new lines**

- After merging the PR, the **active branch shows 20 LOC for the same file (as it ignored the empty lines while in PR the empty line where calculated in LOC)**

- However, `/api/projects/license_usage` appears to report the **LOC from the PR analysis**

We would like to confirm:

1. Is it expected that **PR analyses can influence the LOC reported by `/api/projects/license_usage`** , especially if the PR analysis has more LOC than the active branch?

2. If a **PR with a large number of LOC is scanned and later closed** , could those LOC still temporarily be counted toward license usage?

Additionally, the PR view seems to include **empty lines in the LOC count** , while the documentation states that blank lines should not be counted. Is this expected behavior for PR analysis?

**Server version:** SonarQube Enterprise Edition 2026.1

Sonar Scanner CLI : Latest version

Thank you.

---

<div class="post-metadata">

**Author:** ![warden](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/warden/32/7737_2.png) [@warden](https://community.sonarsource.com/u/warden)\
**Post date:** [March 11, 2026, 11:04pm UTC](https://community.sonarsource.com/t/loc-from-pull-request-appearing-license-usage/179480/2 "2026-03-11T23:04:49Z")

</div>

I think that [the LOC definition documentation](https://docs.sonarsource.com/sonarqube-server/server-update-and-maintenance/monitoring/lines-of-code#calculating-lines-of-code) answers your question, especially the part:

_on the most recent analysis of the largest branch or pull request of the project._

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [March 25, 2026, 10:46am UTC](https://community.sonarsource.com/t/loc-from-pull-request-appearing-license-usage/179480/3 "2026-03-25T10:46:43Z")

</div>

Closed on March 25, 2026, 10:46am UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
