The main branch of this project is empty message in Dashboard

Hi @BorisT ,
Thanks for the screenshot. That looks correct. Have you tried scanning “Development” branch again yet? After setting it as the main branch, you need to scan “Development” branch once more.


Hi @Joe ,

Unfortunately, deleting the project, recreating it, setting Development as the main branch and scanning it several times did not resolve the issue. :frowning:

Is there something else that we can try?

Is there something in configuration files that can cause this issue?
Like in or package.json?


Hi @BorisT ,

I cannot replicate your issue. Can you give me the exact steps in how you are creating this issue so that I can reproduce it?


Is this happening on all your projects or just one project? Are you able to reproduce the problem with a new project?

Hi @Joe ,

This issue happens only in one of two projects.
As far as I can tell, I’m not doing anything different in terms of SonarQube properties or Jenkins pipeline SonarQube setup…

Please let me know what steps/files/configurations you need me to give you.


Hi @BorisT ,

My colleague reminded me of another reason that the “The main branch of this project is empty” message appears: the nloc measure for the main branch of the project is null or equal to 0.

Can you verify there are actual lines of code in your main branch?

In any case, here are the steps that I used to try to reproduce your issue but failed to replicate your scenario:

  1. Provision a new project by clicking on “Create Project” > Manually
  2. Give a project name and project key and click on “Set Up”
  3. Go to Project Settings > Branches & Pull Requests and rename the “master” branch to “develop”
  4. Scan the project making sure that the git branch is “develop” and I use the right project key

Please try my procedure and see if that works for you.

Hi @Joe ,

I checked the line of codes in the project’s Code display and it is indeed Null!
Please refer to the screenshot.

When I took a look at another project, I noticed the same issue.
But, on closer inspection I’ve noticed that *.js files do have a line code count.
The *.ts files are ignored.
Since this is a TypeScript project, I don’t understand why the TypeScript files are not counted…
Please refer to the following screenshot.

Is there a setting I’m missing in the file?
Here’s my configuration:

# Project General Settings
sonar.projectName=server-acme Project

# Source File Inclusions/Exclusions
sonar.exclusions=src/**/*.spec.ts, src/**/*mock*.ts, src/**/*Mock*.ts, src/**/*.test.ts, src/**/*.snap, src/docs/**/*, src/recordings/**/*, src/public/**/*

# Test File Inclusions/Exclusions
sonar.test.inclusions=src/**/*.spec.ts, src/**/*.test.ts

# Linter

# JavaScript/TypeScript Code covarge


Hi @BorisT !

Thanks for confirming the null issue, now that makes sense.

Regarding your other TS project, You should remove the sonar.language=ts parameter since that is not necessary, our scanner will detect the proper language by itself.

Note that your sonar.inclusions says src/**/*.ts, that means only .ts files in the src directory (“Patterns used to include some source files and only these ones in analysis.”). Is that your intent? You are showing the workers folder, which seems to be excluded.

Can you paste the contents of one of those files or take a screenshot and show what SonarQube UI shows when you click on, say, reportWorker.ts?

Hi @Joe,

I’ve removed the sonar.language=ts, but it didn’t change the nloc measure. It is still null for TypeScript.

Yes, we only interested in *.ts files to be scanned (plus one single *.js file)

The screenshot with the workers folder is from another project (with the same issue).
The file for this project looks like this:

# Project General Settings

# Source File Inclusions/Exclusions
sonar.sources=src, DAL, remote, service, userMovements, workers
sonar.inclusions=src/**/*.ts, DAL/**/*.ts, models/**/*.ts, DAL/**/*.ts, remote/**/*.ts, service/**/*.ts, userMovements/**/*.ts, workers/**/*.ts, workers/**/*.js
sonar.exclusions=src/**/*.spec.ts, src/**/*mock*.ts, src/**/*Mock*.ts, src/**/*.test.ts, src/**/*.snap, src/docs/**/*, src/recordings/**/*, src/public/**/*

# Test File Inclusions/Exclusions
sonar.test.inclusions=**/*.spec.ts, **/*.test.ts
sonar.test.exclusions=dist, node_modules, .husky, .vscode, config, diagrams, helm, 

# Linter

# JavaScript/TypeScript Code covarge

The content of reportWorker.ts:

import { mongoDbConnections } from '../mongo-db-connections.service';
import { isMainThread, parentPort } from 'worker_threads';
import { Message } from '../service/pubsub/models/message/message';
import { BBAT } from '../src/BBAT';
import { UserMovementsMapperAndSaver } from '../userMovements/userMovements.service';
import { TimeService } from '../service/time/time.service';
import { ReportWorkerResponse } from './reportWorkerResponse';
import { concatMap, last } from 'rxjs/operators';
import { reject } from 'lodash';
import { Country, TaxMethodTypes } from '../models/bbatReportSummary.model';

const pubsubBBATSubtopicName = 'Start';

async function bbatReportCreation(userId: string) {
	const userMovementsMapperAndSaver = new UserMovementsMapperAndSaver(userId);
	const startTime: number = TimeService.toMillisecondsTimeStamp();
	const movementsCount = await userMovementsMapperAndSaver.saveMovementsInChunks();
	console.log(`===================== number of movements: ${movementsCount} ================`);
	console.log(`======================= for user ${userId} ==========================`);
	const bbat = new BBAT(
		[TaxMethodTypes.FIFO, TaxMethodTypes.FIFO_EXCHANGES, TaxMethodTypes.FIFO_TECH],
	const diff = TimeService.differentInMillisecondsByTimeStamps(startTime);
	console.log(`Fetch and convert movements in ${TimeService.toFormat(diff, 'HH:mm:ss.SSS')}`);

	let deferredResolve: (value: void | PromiseLike<void>) => void;

	const promise = new Promise<void>((resolve, reject) => {
		deferredResolve = resolve;

	(await bbat.createStock())
			concatMap(_ => bbat.createReport())
			complete: () => {
				console.log('Finished calculation job on report worker!');
			error: err => {

	return promise;

async function connect() {
	const promiseBbatConnection = mongoDbConnections.getBbatDbConnection();
	const promiseAcmeConnection = mongoDbConnections.getAcmeDbConnection();
	return await Promise.all([promiseBbatConnection, promiseAcmeConnection]);

async function setupWorker() {
	console.log('Loading BBAT report worker...');
	if (!isMainThread) {
		try {
			await connect();
		} catch (error) {
			console.log(`Failed to initiate MongoDB connection for BBAT - ${error.message}`);
			throw error;

		parentPort.on('message', async (message: Message) => {
			if (message.subTopic === pubsubBBATSubtopicName) {
				try {
					await bbatReportCreation(message.payload.userId);
					parentPort.postMessage({ success: true, data: { message: message } } as ReportWorkerResponse);
				} catch (error) {
						success: false,
						data: { errorMessage: error.message, pubsubMessage: message }
					} as ReportWorkerResponse);
			} else {
				console.warn(`Received unknown message with subtopic ${message.subTopic}. Ignoring.`);

void setupWorker();


Hi @BorisT ,

Apologies for the delay. Here are my observations:

  • sonar.ts.tslintconfigpath=.eslintrc.json is not a valid analysis parameter, does this work? You can delete this parameter.
  • Looking at your reportWorker.ts file reveals that all looks fine. My suggestion, based on your slightly complex sonar.source, inclusions, exclusions settings, is to start from a blank slate and slowly add the following analysis scopes in this order:
    1. Define sonar.exclusions
    2. Once sonar.exclusions looks correct, define sonar.sources
    3. If it looks fine, then define sonar.inclusions

Ideally, you shouldn’t have to define such detailed analysis scope. Usually, sonar.exclusions should be enough. On rare occasions will you need to use sonar.inclusions.

Please try adding each parameter and its values slowly, one by one to deconstruct and hopefully reproduce the issue.


@Joe I’m having this problem with a project that was working fine and that now displays “The main branch of this project is empty” and has characteristics similar to what @BorisT describes. Except that we dont have any inclusions, just exclusions. I dont know when this started displaying that message but it was recent, within the last few weeks.

Ours is a node v12.16.1 project (we have work in progress to bring it up to v16 but thats not happening for a few days or weeks.).

Hi @StingyJack ,

I suggest creating a new thread so they’ll be a greater audience to see your issue.

Have you reviewed this thread yet? There are several things to check here:

If you still need an explanation for your issue, can you attach your DEBUG Sonar scanner analysis logs in the new thread so we can inspect it?

This is the thread that most closely matches the problem I am seeing. I will have to figure out how to get the DEBUG sonar logs. This may require help from another team in my org.

1 Like

It took me a long time to figure this out, but this was in the build information:

WARN: SonarScanner for .NET detected only TEST files and no MAIN files for C# in the current solution. Only TEST-code related results will be imported to your SonarQube/SonarCloud project. Many of our rules (e.g. vulnerabilities) are raised only on MAIN-code. Read more about how the SonarScanner for .NET detects test projects:

The solution was to add this to the non-test csproj files:

  <!-- Project is not a test project -->

I also marked the test projects csproj files with

  <!-- Project is a test project -->

And this was found in our build logs recently…

ERROR: Only Node.js v12.22 or later is supported, got 12.16.1.
org.sonarsource.nodejs.NodeCommandException: Only Node.js v12.22 or later is supported, got 12.16.1.
	at org.sonarsource.nodejs.NodeCommandBuilderImpl.checkNodeCompatibility(
	at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.initNodeCommand(
	at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.startServer(
	at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.startServerLazily(

All of the sonarcloud facilities seem to be working: coverage, duplication, issues, sec hotspots. I can browse the code files in sonarcloud but it just shows 0 lines.

We are updating to node 16 tomorrow, hopefully that will fix the build log issue and the line counting.

1 Like

updating to node v 16 did fix this.


Hi @StingyJack ,

Thanks for coming back to us :+1:.

@BorisT Did you try updating your version of NodeJS? Did that solve the problem?

Hi @Wouter_Admiraal,
I no longer work on this project (the last time I touched it was a long time ago…).
I don’t remember if I update NodeJS version, or not, at the time…

Sorry I couldn’t be more helpful :slightly_frowning_face:

Not at all, thanks for replying :+1: .

In that case, I will mark @StingyJack 's answer as the solution.

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