Analysis fails because excess LOC, but exclusions have no effect

  • ALM used: GitHub
  • CI system used: none for SonarQube Cloud
  • Scanner command used when applicable: N/A
  • Languages of the repository: C / C++
  • Only if the SonarCloud project is public, the URL: private project
  • Error observed:
Last analysis failed
Your analysis with ID "" has failed: your number of lines exceeds your organization plan.
  • Steps to reproduce: merge anything to the main branch
  • Potential workaround: unknown

Hello I have been lurking the forums here for the past few days hoping to find others with my exact problem but it seems most people are using SonarScanner with a CI setup. However, I am trying to use SonarQube Cloud purely through the web UI (sonarcloud.io) if that is possible.

Problem is that we have a 100k line plan and slightly over 115k LOC in our repository, so the analysis scans are failing.

In the root directory, I found one 2.5MB file which was over 60k lines, so I added it to the list of exclusions in <my project>/Administration/Analysis Scope.

For good measure I also added other files and directories which we do not want contributing to our LOC count; some I even repeated with variations like /* or /**

However even after a few more PRs merged to our main branch (called develop), with the most recent analysis (ID: AZOe2LmuKHq_Xf6fa567) Sonar still thinks our LOC is over 100k:

This analysis will make your organization '<censored>' to reach the maximum allowed lines limit (having 119756 lines). 
Please contact the administrator of the organization to resolve this issue.

Looking through Administration / Background Tasks, if I select “Show SonarScanner Context” for the failed analysis, in the Project server settings: section I do see that sonar.coverage.exclusions= is followed by all of the items I added. Also further down this file, I see that sonar.exclusions= has several files listed (but no directories).

What could be preventing these exclusions from reducing our total LOC count?

Plus, another problem, perhaps (un)related:

  • I put // BEGIN-NOSCAN and // END-NOSCAN in a repository file but it seems to have no effect, because I still get issues reported about the contents of that file.
  • :arrow_up:Happy to open a separate ticket/topic about that if preferred

Coverage Exclusions is only preventing your code from being analyzed for code coverage (whether or not it has unit tests covering it). You need to set Source File Exclusions

hi @Colin ,

Thank you for replying and explaining about this.
Okay, we have added the complete list of exclusions to “Source File Exclusions”.

It may be a few days until we merge a PR to this main branch which should trigger a re-scan.
When that happens, I will post an update here.

Confirming that after we merged a PR we were able to successfully get the long-lived branch scanned/analyzed. Thank you for the help @Colin .

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