# Pipeline Task failed because it would exceed LoC limit

**URL:** <https://community.sonarsource.com/t/pipeline-task-failed-because-it-would-exceed-loc-limit/131420>\
**Category:** SonarQube Server / Community Build\
**Tags:** server, pipeline, azure-devops, sonarqube\
**Created:** [December 2, 2024, 3:19pm UTC](https://community.sonarsource.com/t/pipeline-task-failed-because-it-would-exceed-loc-limit/131420 "2024-12-02T15:19:29Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![fsMichael](https://avatars.discourse-cdn.com/v4/letter/f/eada6e/32.png) [@fsMichael](https://community.sonarsource.com/u/fsMichael)\
**Post date:** [December 2, 2024, 3:19pm UTC](https://community.sonarsource.com/t/pipeline-task-failed-because-it-would-exceed-loc-limit/131420/1 "2024-12-02T15:19:29Z")

</div>

## **Description of the Issue**

Hello everyone,  
I’m currently facing an issue and would really appreciate your help. Below is a detailed description of the problem:

**Problem:**  
Last month, we added a large feature to our main branch. Since then, our pipeline task in Azure DevOps has stopped working. Interestingly, pull requests with smaller-scale changes still work fine.

**Expected Behavior:**  
We have a limit of 500k lines of code (LoC). Before merging the feature, we used approximately 350k LoC. The new feature adds about 46k LoC, so it should still be well within the limit.

**Actual Behavior:**  
Despite our calculations, the `Publish Quality Gate Result` task fails during execution with the following error message:

```auto
2024-12-02T14:29:22.9780048Z ##[section]Publish Quality Gate Result wird gestartet.
2024-12-02T14:29:22.9918204Z ==============================================================================
2024-12-02T14:29:22.9918273Z Task : Publish Quality Gate Result
2024-12-02T14:29:22.9918320Z Description : Publish SonarQube's Quality Gate result on the Azure DevOps build result, to be used after the actual analysis.
2024-12-02T14:29:22.9918383Z Version : 6.3.2
2024-12-02T14:29:22.9918410Z Author : sonarsource
2024-12-02T14:29:22.9918444Z Help : [More Information](https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/scanners/sonarqube-extension-for-azure-devops/)
2024-12-02T14:29:22.9918521Z ==============================================================================
2024-12-02T14:30:27.2316714Z ##[warning]Error while executing SonarQube:Publish task: [SQ] Task failed with status FAILED, Error message: The last analysis failed because it would have caused your server-wide lines of code total to exceed your 500000 limit.
2024-12-02T14:30:27.2317582Z ##[error][SQ] Task failed with status FAILED, Error message: The last analysis failed because it would have caused your server-wide lines of code total to exceed your 500000 limit.
2024-12-02T14:30:27.2370522Z ##[section]Publish Quality Gate Result wird fertiggstellt

```

## **Environment Details**

Here are some details about my setup that might be helpful:

- **SonarQube Server:** Version 10.7 (zip installation)
- **Build Agent:** Self-managed Windows 10 Virtual Machines (same behavior on both agents)
- **Pipeline Task:** Version 6.3.2 (DevOps 19.225.35005.1)
- **Azure DevOps:** Version 19.225.35005.1

* * *

## **Steps Taken to Troubleshoot**

We have already tried the following steps, but the issue persists:

1. Updated the SonarQube Server from version 10.6 to 10.7.
2. Updated pipeline tasks from version 5.\* to 6.\*.
3. Reviewed source files for exclusions from analysis.
4. Verified the LoC calculations in VS2022 both before and after merging the feature.

* * *

## **Questions and Next Steps**

- Could there be a discrepancy in how LoC are calculated by SonarQube vs. our manual calculations?
- Is there a specific configuration or setting we might have overlooked?

If you need any further information or logs, please let me know, and I will provide them as quickly as possible.

Thanks in advance for your help!  
Michael

---

<div class="post-metadata">

**Author:** ![denis.troller](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/denis.troller/32/49117_2.png) [@denis.troller](https://community.sonarsource.com/u/denis.troller)\
**Post date:** [December 3, 2024, 12:38pm UTC](https://community.sonarsource.com/t/pipeline-task-failed-because-it-would-exceed-loc-limit/131420/3 "2024-12-03T12:38:47Z")

</div>

Hi @fsMichael, welcome to the community!

Can you please share

- your (redacted) pipeline
- the (redacted) logs of the SonarQubePrepare & SonarQubeAnalyze, with the extra property `sonar.verbose=true`

Denis

---

<div class="post-metadata">

**Author:** ![fsMichael](https://avatars.discourse-cdn.com/v4/letter/f/eada6e/32.png) [@fsMichael](https://community.sonarsource.com/u/fsMichael)\
**Post date:** [December 3, 2024, 2:51pm UTC](https://community.sonarsource.com/t/pipeline-task-failed-because-it-would-exceed-loc-limit/131420/5 "2024-12-03T14:51:31Z")

</div>

Hi Denis, thanks for your fast response!

I did attache the [SonarqubePrepare.log](https://community.sonarsource.com/uploads/short-url/6BEEbWXT1XRpaYNDwkbCZMgG0zL.log) (9.6 KB) and removed all GUIDs and company related information. The analysis task log contains all our project names. I am not allowed to publish this information. Can you lead me in a specific direction, what you are looking for? Otherwise I have to X-out all names of 130 projects. Please let me know.

You also requested “(redacted) pipeline”. I can not freely publish all logs and I need to mention, it’s a classic pipeline. The only option i have, is to export yaml scripts for each task. I did upload a screenshot of the pipeline UI.

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/5/1/51225bbdbf3b826eac5f471cc0adc747b7e94d6e.png)  
Best regards  
Michael

---

<div class="post-metadata">

**Author:** ![denis.troller](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/denis.troller/32/49117_2.png) [@denis.troller](https://community.sonarsource.com/u/denis.troller)\
**Post date:** [December 3, 2024, 5:08pm UTC](https://community.sonarsource.com/t/pipeline-task-failed-because-it-would-exceed-loc-limit/131420/6 "2024-12-03T17:08:06Z")

</div>

Thanks, @fsMichael

On the pipeline I would need the configuration of the Prepare Analysis task (an export to YAML, removing tokens and other security-sensitive information would be perfect, actually).

As for the log of the Analyze task, if you want you can send it by private message so it is not exposed here. I do not know what I am looking for to be honest, so it is difficult to guide you here.

Denis

---

<div class="post-metadata">

**Author:** ![fsMichael](https://avatars.discourse-cdn.com/v4/letter/f/eada6e/32.png) [@fsMichael](https://community.sonarsource.com/u/fsMichael)\
**Post date:** [December 3, 2024, 5:44pm UTC](https://community.sonarsource.com/t/pipeline-task-failed-because-it-would-exceed-loc-limit/131420/7 "2024-12-03T17:44:51Z")

</div>

Hi Denis,

here are the yaml tasks.  
[PrepareSonarqube.txt](https://community.sonarsource.com/uploads/short-url/vY9NAMo62vNk8QzoHoi2wEfNmjm.txt) (766 Bytes)  
[AnalysisSonarqube.txt](https://community.sonarsource.com/uploads/short-url/uj6T3xZoOifr1SlZd6OUOmzQwxE.txt) (228 Bytes)  
[PublishSonarqube.txt](https://community.sonarsource.com/uploads/short-url/b446d52TH0SCie5gNfuetjc7h8C.txt) (198 Bytes)

I would send you the log file via private message, as you suggest, but it’s not possible, because I am a fresh user. If we find any hints, we can repost it here afterwards.

Michael

---

<div class="post-metadata">

**Author:** ![fsMichael](https://avatars.discourse-cdn.com/v4/letter/f/eada6e/32.png) [@fsMichael](https://community.sonarsource.com/u/fsMichael)\
**Post date:** [December 5, 2024, 9:03am UTC](https://community.sonarsource.com/t/pipeline-task-failed-because-it-would-exceed-loc-limit/131420/8 "2024-12-05T09:03:20Z")

</div>

Hi Denis,

i talked to my boss and we decided to share a download link for a day. I hope this will work for you.

> **[Sonarissues](https://cloud.firesys.de/d/426c7caeba8647fc873c/)**
>
> Share link for Sonarissues.

Thanks in advance  
Michael

---

<div class="post-metadata">

**Author:** ![denis.troller](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/denis.troller/32/49117_2.png) [@denis.troller](https://community.sonarsource.com/u/denis.troller)\
**Post date:** [December 5, 2024, 10:06am UTC](https://community.sonarsource.com/t/pipeline-task-failed-because-it-would-exceed-loc-limit/131420/9 "2024-12-05T10:06:14Z")

</div>

Thanks, @fsMichael

One question: When you say you added a large feature of about 46k LoCs, are you accounting for other languages that would be included in the project (as content for example)?  
I’m thinking about large XML files, since this seems to be the only other language present in your project (usually 1 to 3 files, but one project has 24 and the other has 32).

Denis

---

<div class="post-metadata">

**Author:** ![fsMichael](https://avatars.discourse-cdn.com/v4/letter/f/eada6e/32.png) [@fsMichael](https://community.sonarsource.com/u/fsMichael)\
**Post date:** [December 5, 2024, 10:38am UTC](https://community.sonarsource.com/t/pipeline-task-failed-because-it-would-exceed-loc-limit/131420/10 "2024-12-05T10:38:10Z")

</div>

Hi Denis,

if you talk about the TestAssets Namespace in toolsxbrl.core.test project, I can say, that my calculation don’t include this files in my calculation. I thought it doesn’t matter because it’s in a dedicated test project. Do you suggest, excluding them in the analysis scope:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/6/e/6e755b0fd5d82cabf4471c01752d9cb11cf679b8.png)

Michael

---

<div class="post-metadata">

**Author:** ![denis.troller](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/denis.troller/32/49117_2.png) [@denis.troller](https://community.sonarsource.com/u/denis.troller)\
**Post date:** [December 5, 2024, 12:57pm UTC](https://community.sonarsource.com/t/pipeline-task-failed-because-it-would-exceed-loc-limit/131420/11 "2024-12-05T12:57:46Z")

</div>

It might be that, I’m not sure. If the scanner has trouble categorizing the project then they could be counted towards the LoCs.  
There’s also the XML config files for UI things such as Ribbon config in the VSTO and [FIRE.sys.net](http://FIRE.sys.net) projects. No idea how big these are.

Denis

---

<div class="post-metadata">

**Author:** ![fsMichael](https://avatars.discourse-cdn.com/v4/letter/f/eada6e/32.png) [@fsMichael](https://community.sonarsource.com/u/fsMichael)\
**Post date:** [December 5, 2024, 4:16pm UTC](https://community.sonarsource.com/t/pipeline-task-failed-because-it-would-exceed-loc-limit/131420/12 "2024-12-05T16:16:28Z")

</div>

It seems, that the exclusion don’t work at all… I will investigate that first and get back to you, if i get further information. Thanks for pointing in the right direction.

Michael

---

<div class="post-metadata">

**Author:** ![fsMichael](https://avatars.discourse-cdn.com/v4/letter/f/eada6e/32.png) [@fsMichael](https://community.sonarsource.com/u/fsMichael)\
**Post date:** [December 9, 2024, 10:20am UTC](https://community.sonarsource.com/t/pipeline-task-failed-because-it-would-exceed-loc-limit/131420/13 "2024-12-09T10:20:24Z")

</div>

After excluding the .xml files in the pipeline prepare task, it worked. In our setup the SonarQube UI for the webbrowser seems to have no effect at all.

#Your build pipeline references an undefined variable named ‘Parameters.projectKey’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See [YAML schema reference | Microsoft Learn](https://go.microsoft.com/fwlink/?linkid=865972)

```auto
#Your build pipeline references an undefined variable named ‘Parameters.projectKey’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972

steps:
- task: sonarsource.sonarqube.15B84CA1-B62F-4A2A-A403-89B77A063157.SonarQubePrepare@6
  displayName: 'Prepare analysis on SonarQube'
  inputs:
    SonarQube: Sonar
    projectKey: '$(Parameters.projectKey)'
    projectName: 'Quality Check'
    extraProperties: |
     # Additional properties that will be passed to the scanner, 
     # Put one key=value per line, example:
     sonar.exclusions= **/*.bin,** /*.xml,**/*.xsd
     sonar.vbnet.vscoveragexml.reportsPaths=**/*.coveragexml
     sonar.verbose=true

```

Thanks Denis!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [December 16, 2024, 10:21am UTC](https://community.sonarsource.com/t/pipeline-task-failed-because-it-would-exceed-loc-limit/131420/14 "2024-12-16T10:21:15Z")

</div>

Closed on December 16, 2024, 10:21am UTC

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