Analysis fails due to "LICENSING_LOC" after upgrade to 9.0.1


We’re running our analysis in GitHub Actions with self-hosted SonarQube:

  • SonarQube
  • SonarScanner
  • Java 11.0.11 AdoptOpenJDK (64-bit)

A project that used to work started to fail after we upgraded from 8.7 to 9.0

“The last analysis failed because it would have caused your server-wide lines of code total to exceed your 250000 limit.”
This is unexpected as there are still roughly 16k LoC left in the license, the threshold is set to 5k and there have been minimal changes in the repository: between the last working and the first non-working scan, there’s the same number of files being analysed and excluded. Diff to master in the first failing scan is just a few lines: there are no new files or even new lines added.

We have not changed anything in the github actions job or, and unnecessary code is excluded as before.
What could be the cause?

In case it matters, the project has only ever analysed PRs. The main branch (or, indeed, any branch) has not been analysed, and the changed lines have been updates to python modules, but we haven’t been able to find anything that they’d have added.

Is there any way to verify how many lines the analysis would have covered? Any help wrt. debugging this would be appreciated.

I’m not aware of any change between 8.7 and 9.0 that could impact the count of lines of code.
Is it only happening for one project? What nloc do you see in {server_url}/api/navigation/marketplace?

Hi! 232222 is the number of lines we have currently, meaning we still have ~12k LoC “left” of our license.

We just updated our test instance to 9.1 so now I can use the server logs there to show the number of LoCs also for the failed builds.

  • If I scan the commit that was the last that passed in our prod SQ, the logs show it has 78073 LoC.
  • The next one, the first to fail in prod, had exactly the same, 78073, since there were only a couple of changes to some lines.
  • Even the latest commit (no scans have succeeded after the first one that failed) has 82221

So even at the largest, the difference is only 4148, which is considerably fewer lines than 12k. So this problem really boggles my mind :sweat_smile:

Only branches (not PRs) count for the license. However, when a project is analyzed, the lines being analyzed are included in the calculation.
So I’m thinking that maybe you have 12k LoC left without counting the project being analyzed, since you mentioned that it has no regular branch. When you analyze a PR of that project, the license check sees 232222+78073, which is above 250000.
Maybe when it previously succeeded, the total LOC in SQ was at a point that wouldn’t fail with those additional 78k.

Wow, this explains everything. We now got SQ 9.1 in Production and I can confirm that indeed this was the case.

I’m sure projects without branches are a weird corner case, but boy did it cause a lot of confusion for our team! I started to think maybe I don’t quite understand how New Code works and something related to that changed in 8->9 upgrade, or something was not working as expected wrt. branches in project.
We’ll get more LoCs soon, so that will finally solve that issue.

Ok, thanks for confirming.
We are fixing that in 9.2 to make things clearer: [SONAR-15450] Take pull requests into account when counting instance's NLOC - SonarSource

1 Like

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