The main branch of this project is empty

Version 9.9 (build 65466)

We have been successfully using Sonarqube for a number of years with our .NET applications.

On our latest project we are encountering an issue where we get this message:
‘The main branch of this project is empty.’

This new project initially had a ‘main’ branch and Sonarqube was run against this branch. We have since created a new ‘master’ branch and removed the ‘main’ branch.

We have tried deleting the project and rerunning the analysis and we have updated our azure pipelines to include:

sonar.branch.name=master
sonar.projectCreation.mainBranchName=master

We have also updated the Default main branch name within Sonarqube Administration.

The Sonarqube logs in the azure pipeline logs look to be analysing the correct projects.

Any help would be really appreciated.
Thanks
Lee

Hi Lee,

First, sonar.projectCreation.mainBranchName cannot be set in analysis properties. It’s a global property and can only be set, at the global level, in the UI.

But on that topic, what is your global property set to?

 
Ann

Hi Ann,

Are you talking about the Default main branch name in the administration section?

Default main branch name

Each project has a main branch at creation. This setting defines the instance-wide default main branch name. A user can override this when creating a project. This setting does not apply to projects imported from a DevOps platform.

That is set to master although the guidance suggests the branch will be picked up devops, which is what we use.

Our devops repo has a single branch, master.

image

Hi Lee,

Yes, that’s what I was asking.

Okay, so your project initially had a main branch but now has a master branch. You’ve deleted it and reanalyzed and you see this “main branch… is empty” message.

What shows up in the branches dropdown? Does master show up in the list as a non-main branch?

And can you post your master 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.

 
Thx,
Ann

Master is the default and only branch in DevOps.

I am just confirming with our support guys that its ok send the file. What i have noticed in the analysis file is that all the source code is skipped to it being a test file?

Example:
2024-09-26T07:20:25.5005849Z 07:20:25.495 DEBUG: Skipping ‘/__w/26/s/Imagesound.Remote.Api/Extensions/ControllerExtensions.cs’ as it is a test file.

sonarqube.txt (708.7 KB)

Please find attached the analysis log.

Hi,

Thanks for the log. And without a deep dive into it, I can confidently say you’ve already found the problem:

These docs should help.

 
Ann

Why would sonarqube suddenly start skipping code files and categorising them as test files?

Hi,

We’ve seen stuff categorized as tests because e.g. a test-related dependency was added. The docs I linked will help you sort this out.

 
Ann

ok thanks.