0 lines of code in project

Hi team,

We’ve been trying to add sonarcloud analysis to an exising yaml pipelines in azure devops with the source code also being on azure devops. The project in question is for a dotnet 7. But regardless of what we do, the project is constantly showing with 0 lines of code. We made changes to the original pipeline, recreated the project in sonarcloud and even changed the build agent requirement for the pipeline but to no avail. Looking at the source tab in sonarcloud we see the folder structure but without the code files.

Myself and the team have added dozen of such analysis so we are a bit puzzled to what’s happening.

Can you please help us.


1 Like


Welcome to the community!

Can you share the analysis log?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.


Hi Ann,

Please find the log in the attached file.

SonarAnalysis - zero lines.zip (157.3 KB)


I guess this is a branch analysis with no changed files?

Because the log definitely shows files being indexed and analyzed. But then we get to this:

2023-01-10T17:35:23.0710019Z 17:35:23.057 DEBUG: SCM reported changed lines for 0 files in the branch

And backing up to the analysis params, I see this:

2023-01-10T17:33:31.2139755Z ##[debug]SONARQUBE_SCANNER_PARAMS={..."sonar.branch.name":"Filipe-Test"...}

Short-lived branch and PR analysis are designed to narrow analysis to give you an assessment of the changes. So when nothing’s changed, it’s quite normal to see 0 lines of code.



Yes, that’s is correct. Short-lived branches are indeed only expected to add the track the new lines added on that branch. However, the main branch count is zero as well, and since I was trying to solve the issue, I created a branch to change the pipeline. I attach a screenshot of the main branch analysis (with overall code selected) and the log of a main branch anlysis (unfortunately, no debug information there). If you need it, please let me know and I’ll try to get that for you.


SonarAnalysis - zero lines - main.txt (80.3 KB)


Tell me about these missing files? You’re expecting to see .cs files in your analysis, and they’re missing? Because I see this in your log:

2023-01-11T09:48:57.5961114Z WARN: Your project contains C# files which cannot be analyzed with the scanner you are using. To analyze C# or VB.NET, you must use the SonarScanner for .NET 5.x or higher, see https://redirect.sonarsource.com/doc/install-configure-scanner-msbuild.html

Tangentially & unrelated, I also see this:

2023-01-11T09:48:57.6336898Z WARN: Shallow clone detected, no blame information will be provided. You can convert to non-shallow with 'git fetch --unshallow'.


Update for this one. We did a bit of a left turn and atempted to setup a new repository with the existing code. So we transferred the content to the new repo and we are seeing this behaviour:

  1. Main branch builds but no lines of code are detected (yes, even from the first ever build).
  2. If a different branch builds before the main branch, we see the lines of code listed but nothing is reported (0 code sniffs in almost 200k lines is suspicious).
  3. Doing a pull request and building on the main branch results in 0 lines of code found.

I’m attaching to result of the run of point 2. Any help to what we should be looking for is appreciated.
SonarAnalysis - new feature branch.txt (81.3 KB)


2023-01-16T10:24:34.9358385Z ##[section]Starting: SonarCloudAnalyze
2023-01-16T10:24:34.9363382Z ==============================================================================
2023-01-16T10:24:34.9363733Z Task         : Run Code Analysis
2023-01-16T10:24:34.9363858Z Description  : Run scanner and upload the results to the SonarCloud server.
2023-01-16T10:24:34.9364061Z Version      : 1.34.0
2023-01-16T10:24:34.9364178Z Author       : sonarsource
2023-01-16T10:24:34.9364305Z Help         : Version: 1.34.0. This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

Am I correct in thinking that you’re using version 1.34 of the SonarCloud Azure DevOps task? Because the current version is 5.4…

Can you make sure you’re on the latest of everything and try again?

Also, you really should fix this:

2023-01-16T10:25:00.3106391Z WARN: Shallow clone detected, no blame information will be provided. You can convert to non-shallow with 'git fetch --unshallow'.


Hi Ann,

I was checking this again today and with a colleague we were able to fix the issue.

For anyone looking at this thread in the future potentialy facing the same issue and looking for a response, the problem was that we were analysing and dotnet build task with a sonarcloud configured for a CLI build. It was not the first time we were using this configuration, but it was the first time we experienced this error. So after making the on the prepare analysis step to integrated MSbuild, the issue was soved.

Thanks for your help!

1 Like

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