It used to run in short-lived branches and didn't count toward LOC. Now, it counts LOC for every

Hello,

We have Teams plan for 100k LOC. We are facing an issue in SonarCloud regarding how Lines of Code (LOC) are being counted. Previously, when analysis was executed on short-lived branches, the LOC from those branches was not counted toward the organization’s LOC limit. However, recently we observed that LOC is being counted for every branch analysis, including short-lived branches. Because of this change, our organization is quickly reaching the LOC limit even though most of the analyses are from temporary development branches. This behavior is impacting our CI/CD workflow and preventing further analyses due to the LOC restriction. We would like clarification on why this change occurred and whether there is a way to prevent short-lived branch analyses from counting toward the total LOC.

So the issue is like below:

We are on the Teams plan for our organization opplaybook. We are experiencing an issue where analyzing a short-lived branch is being blocked by the LOC limit, which should not happen according to SonarCloud documentation.

Issue:
When running analysis on branch test-sonar (which is correctly classified as a short-lived branch in our project opplaybook_playbookweb-1), we get the following error:

“This analysis will make your organization ‘opplaybook’ to reach the maximum allowed lines limit (having 139196 lines). Please contact the administrator of the organization to resolve this issue.”

What we have done:

  • Confirmed test-sonar is listed under Short-lived branches in project branch settings
  • Set long-lived branch pattern to ^(main|master)$ so only main and master are long-lived
  • master branch has never been analyzed
  • Even creating a brand new project in the same org hits the same LOC limit error

Expected behavior:
Short-lived branches should not count toward the LOC limit as per SonarCloud documentation.

Questions:

  1. Why is a short-lived branch triggering the LOC limit?
  2. Is our org LOC quota being consumed incorrectly?
  3. How can we resolve this without upgrading our LOC limit?

Please advise.

Thanks

Hi,

For each project, the largest branch or PR is what counts toward the License LOC. Since short-lived branches only cover new code, they’re typically smaller than the long-lived branches, but that doesn’t mean they’re not eligible to be counted toward the license.

At a guess, you’ve added something in this branch that you didn’t intend to analyze. Or perhaps you’ve changed configurations to include previously-excluded code. Your best option here is to add -Dsonar.verbose=true to the analysis command line. Among other things, this will cause each file to be echoed to the log as its indexed. You can then check the list of files being included in analysis to see what’s there that shouldn’t be.

 
HTH,
Ann