Getting The main branch of this project is empty while building my project

I am using sonarqube to check the code quality of my test scripts.I dont have the main source code in my project as It only consists test scripts. After building my project I am getting message “The main branch of this project is empty.” and all metrics are 0 on sonar dashboard.What should I do if I have to check the quality of test script also.

I have tried to explicitly define sonar.source to src/test/java but It didnt work at all.Please help

Hi,

Welcome to the community!

Somehow your definition of sonar.sources isn’t working. You wrote sonar.source. Was that a typo in your composition of this post, or is that actually what you set? Because the recognized parameter ends with an ‘s’.

BTW, you’re seeing the message that your project is empty because your files are being analyzed as tests and so no LOC count is being calculated. It’s that metric, specifically, that the project homepage keys on to know whether or not to draw itself. Once you get sonar.sources sorted out, this problem should go away.

BTW, how are you analyzing? With Maven? And what’s your analysis command?

 
Ann

Hi Ann,

Thank you so much for the reply and sorry for too much delay in the reply.Actually it was a typo in sonar.source. I used exact sonar.sources in the configuration but it didnt work.

I have defined sonar.sources in build.gradle file as:

3

Still it shows “The project is empty”.

I don’t know whether it is analyzing my project or not. And if it is analyzing then why it is not showing any bug, vulnerability or defect etc.

Please have a look on my project’s structure:

When I open my project on sonar server and goes to the code section it shows as:

After opening the folder structure:

gradle clean sonarqube

and for maven i am using mvn clean sonar:sonar

Hi,

you might use
https://github.com/SonarSource/sonar-scanning-examples/tree/master/sonarqube-scanner-gradle
for a quick test if it works correctly.

Gilbert

Hi Gilbert,

Actually the project which you provided above consist a main source file (App.java) whose unit test is written in AppTest.java in test folder. So here the sonar will analyse the code because main source code is available but my primary problem is that my framework does not consist main source code as I have a automation testing framework which have no main package (only consists test scripts in test folder).Can you please check it without source code.

Regards,
Shadab

Hi Shadab,

I think instead of setting sonar.sources to src you need to set it to src/test.

 
HTH,
Ann

Hi Ann,

It is still not working…I tried the same (src/test) for sonar source

subprojects {
sonarqube {
properties {
property “sonar.sources”, “src/test”
}
}
}

Is there any other sonar configuration which is overriding my configuration?

Hi,

did you already check the global | project settings for exclusions in Sonarqube server ?
Should also be seen in the analysis logs.

Gilbert

Hi guys,

I think at this point it will be useful to use the sonar.scanner.dumpToFile parameter (you’ll need to provide a file name as the value) so we can see what value sonar.sources, and also maybe sonar.tests actually end up with.

 
Ann