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_usageappears to report the LOC from the PR analysis
We would like to confirm:
-
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? -
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.