LOC from Pull Request appearing license_usage

Hello,

We are reviewing our SonarQube license usage using the API:

/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.

I think that the LOC definition documentation answers your question, especially the part:

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

2 Likes

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