[Error] :: The main branch has no lines of code

Template for a good bug report, formatted with Markdown:

  • versions used - SonarQube - 7.9.1 (build 27448)
  • error observed - On Overview page - The main branch has no lines of code.
  • steps to reproduce - Used Sonar scanner and pushed a build.
  • potential workaround - Not that I can found.

We have an Enterprise edition of Sonar and Teamcity and pushing analysis from a build step. The report is pushed but the sonar project page shows “The main branch has no lines of code.”.

Teamcity Logs

[15:32:50]|Step 7/7: [mandatory] :: sonar analysis (SonarQube Runner) (19s)
[15:32:50]|[Step 7/7] Starting SQS from D:\BuildAgent\tools\sonar-qube-scanner.3.0.3.778-scanner|
[15:32:50]|[Step 7/7] -classpath|
[15:32:50]|[Step 7/7] D:\BuildAgent\tools\sonar-qube-scanner.3.0.3.778-scanner\lib\sonar-scanner-cli-3.0.3.778.jar|
[15:32:50]|[Step 7/7] org.sonarsource.scanner.cli.Main|
[15:32:50]|[Step 7/7] -Dproject.home=.|
[15:32:50]|[Step 7/7] -Dsonar.host.url=https://sonar-3.abc.ab.abcdef.net/|
[15:32:50]|[Step 7/7] -Dsonar.projectKey=FIDP_SD_SDNC|
[15:32:50]|[Step 7/7] -Dsonar.projectName=S D .NET C|
[15:32:50]|[Step 7/7] -Dsonar.projectVersion=1.1.0-alpha.1|
[15:32:50]|[Step 7/7] -Dsonar.sources=src|
[15:32:50]|[Step 7/7] -Dsonar.tests=.tests|
[15:32:50]|[Step 7/7] -Dsonar.binaries=.output|
[15:32:50]|[Step 7/7] -Dsonar.java.binaries=.output|
[15:32:50]|[Step 7/7] -Dsonar.password=Sonar_Password|
[15:32:50]|[Step 7/7] -Dsonar.login=Sonar_Username|
[15:32:50]|[Step 7/7] -X|
[15:32:50]|[Step 7/7] -Dsonar.language=cs|
[15:32:50]|[Step 7/7] -Dsonar.fxcop.mode=skip|
[15:32:50]|[Step 7/7] -Dsonar.scm.disabled=true|
[15:32:50]|[Step 7/7] -Dsonar.dotnet.test.assemblies=.tests\*Test*.dll|
[15:32:50]|[Step 7/7] -Dsonar.sourceEncoding=UTF-8|
[15:32:50]|[Step 7/7] -Dsonar.projectDescription=S D .NET C|
[15:32:50]|[Step 7/7] -Dsonar.dotnet.visualstudio.solution.file=src\ABC.FR.Plat.SD.sln|
[15:32:50]|[Step 7/7] -Dsonar.test.inclusions=file:**/**/*.Test/**/**|
[15:32:50]|[Step 7/7] -Dsonar.gallio.mode=reuseReport|
[15:32:50]|[Step 7/7] -Dsonar.gallio.reports.path=gallio-report.xml|
[15:32:50]|[Step 7/7] -Dsonar.gallio.coverage.reports.path=results.xml|
[15:32:50]|[Step 7/7] -Dsonar.buildbreaker.queryMaxAttempts=400|
[15:32:50]|[Step 7/7] -Dsonar.cs.dotcover.reportsPaths=dotcover.html|
[15:32:50]|[Step 7/7] -Dscanner.home=D:\BuildAgent\tools\sonar-qube-scanner.3.0.3.778-scanner|
[15:32:50]|[Step 7/7] Starting: D:\BuildAgent\jre\bin\java.exe -classpath D:\BuildAgent\tools\sonar-qube-scanner.3.0.3.778-scanner\lib\sonar-scanner-cli-3.0.3.778.jar org.sonarsource.scanner.cli.Main -Dproject.home=. -Dsonar.host.url=https://sonar-3.abc.ab.abcdef.net/ -Dsonar.projectKey=FIDP_SD_SDNC -Dsonar.projectName=S D .NET C -Dsonar.projectVersion=1.1.0-alpha.1 -Dsonar.sources=src -Dsonar.tests=.tests -Dsonar.binaries=.output -Dsonar.java.binaries=.output -Dsonar.password=Sonar_Password -Dsonar.login=Sonar_Username -X -Dsonar.language=cs -Dsonar.fxcop.mode=skip -Dsonar.scm.disabled=true -Dsonar.dotnet.test.assemblies=.tests\*Test*.dll -Dsonar.sourceEncoding=UTF-8 -Dsonar.projectDescription=S D .NET C -Dsonar.dotnet.visualstudio.solution.file=src\ABC.FR.Plat.SD.sln -Dsonar.test.inclusions=file:**/**/*.Test/**/** -Dsonar.gallio.mode=reuseReport -Dsonar.gallio.reports.path=gallio-report.xml -Dsonar.gallio.coverage.reports.path=results.xml -Dsonar.buildbreaker.queryMaxAttempts=400 -Dsonar.cs.dotcover.reportsPaths=dotcover.html -Dscanner.home=D:\BuildAgent\tools\sonar-qube-scanner.3.0.3.778-scanner|
[15:32:50]|[Step 7/7] in directory: D:\data\BuildAgent\work\9cbbe01fb74751ce|
[15:32:51]|[Step 7/7] 11:02:51.294 INFO: Scanner configuration file: D:\BuildAgent\tools\sonar-qube-scanner.3.0.3.778-scanner\conf\sonar-scanner.properties|
[15:32:51]|[Step 7/7] 11:02:51.300 INFO: Project root configuration file: NONE|
[15:32:51]|[Step 7/7] 11:02:51.325 INFO: SonarQube Scanner 3.0.3.778|
[15:32:51]|[Step 7/7] 11:02:51.326 INFO: Java 1.8.0_66 Oracle Corporation (32-bit)|
[15:32:51]|[Step 7/7] 11:02:51.326 INFO: Windows Server 2012 R2 6.3 x86|
[15:32:51]|[Step 7/7] 11:02:51.495 DEBUG: keyStore is : |
[15:32:51]|[Step 7/7] 11:02:51.495 DEBUG: keyStore type is : jks|
[15:32:51]|[Step 7/7] 11:02:51.495 DEBUG: keyStore provider is : |
[15:32:51]|[Step 7/7] 11:02:51.495 DEBUG: init keystore|
[15:32:51]|[Step 7/7] 11:02:51.496 DEBUG: init keymanager of type SunX509|
[15:32:51]|[Step 7/7] 11:02:51.640 INFO: User cache: C:\Users\svc-fld\.sonar\cache|
[15:32:51]|[Step 7/7] 11:02:51.640 DEBUG: Extract sonar-scanner-api-batch in temp...|
[15:32:51]|[Step 7/7] 11:02:51.651 DEBUG: Get bootstrap index...|
[15:32:51]|[Step 7/7] 11:02:51.651 DEBUG: Download: https://sonar-3.abc.ab.abcdef.net/batch/index|
[15:32:52]|[Step 7/7] 11:02:51.998 DEBUG: Get bootstrap completed|
[15:32:52]|[Step 7/7] 11:02:51.999 DEBUG: Create isolated classloader...|
[15:32:52]|[Step 7/7] 11:02:52.010 DEBUG: Start temp cleaning...|
[15:32:52]|[Step 7/7] 11:02:52.018 DEBUG: Temp cleaning done|
[15:32:52]|[Step 7/7] 11:02:52.019 DEBUG: Execution getVersion|
[15:32:52]|[Step 7/7] 11:02:52.025 DEBUG: Execution start|
[15:32:52]|[Step 7/7] 11:02:52.035 DEBUG: Execution getVersion|
[15:32:52]|[Step 7/7] 11:02:52.035 INFO: SonarQube server 7.9.1|
[15:32:52]|[Step 7/7] 11:02:52.035 INFO: Default locale: en_GB, source code encoding: UTF-8|
[15:32:52]|[Step 7/7] 11:02:52.036 DEBUG: Work directory: D:\data\BuildAgent\work\9cbbe01fb74751ce\.scannerwork|
[15:32:52]|[Step 7/7] 11:02:52.036 DEBUG: Execution getVersion|
[15:32:52]|[Step 7/7] 11:02:52.036 DEBUG: Execution execute|
[15:32:52]|[Step 7/7] 11:02:52.409 WARN: SonarScanner will require Java 11+ to run starting in SonarQube 8.x|
[15:32:52]|[Step 7/7] 11:02:52.411 DEBUG: Enterprise 7.9.1.27448|
[15:32:52]|[Step 7/7] 11:02:52.573 INFO: Load global settings|
[15:32:52]|[Step 7/7] 11:02:52.961 DEBUG: GET 200 https://sonar-3.abc.ab.abcdef.net/api/settings/values.protobuf | time=385ms|
[15:32:53]|[Step 7/7] 11:02:53.033 INFO: Load global settings (done) | time=460ms|
[15:32:53]|[Step 7/7] 11:02:53.042 INFO: Server id: 8FCD67FD-1f91bc9d792e6f3|
[15:32:53]|[Step 7/7] 11:02:53.066 INFO: User cache: C:\Users\svc-fld\.sonar\cache|
[15:32:53]|[Step 7/7] 11:02:53.070 INFO: Load/download plugins|
[15:32:53]|[Step 7/7] 11:02:53.070 INFO: Load plugins index|
[15:32:53]|[Step 7/7] 11:02:53.315 DEBUG: GET 200 https://sonar-3.abc.ab.abcdef.net/api/plugins/installed | time=245ms|
[15:32:53]|[Step 7/7] 11:02:53.382 INFO: Load plugins index (done) | time=312ms|

---

[15:33:10]|[Step 7/7] 11:03:10.456 INFO: Analysis report uploaded in 301ms

Hi,

Welcome to the community!

What languages are in your project?

 
Ann

Hi @ganncamp,

Thanks for the reply.

Ours is a .Net project in C# language. We are using Sonar Qube runner and not Sonar .Net tool (yet!)

I truncated the logs due to question box word limit. Can provide detailed logs, if you can pls provide a link to upload them.

Cheers!
Nikhil

Hi Nikhil,

Okay! I thought they were strangely short. Now I understand why :joy:

For C# you’re going to need to use the Scanner for .NET to get good results - or really, any results at all I think. Please give that a go.

 
Ann

Hi @ganncamp,

What is the surety that this would not happen in Scanner for .Net?

We are using a common Teamcity template to build and push to Sonar. Many successful builds are using the same template. It’s just that a few of them have this issue. The code located inside the codebase, parameters, BitBucket default branch etc. is the same for all builds.

Still, I am in a fix as to how it works for one and not for another. I have admin rights on the sonar project and deleted it also. The TeamCity build automatically creates the sonar project if it does not exist. The new project created still have this issue.

I’ll be more than happy to send over both logs - a working build and a non-working one.

Cheers,
Nikhil

Hi,

Are the ones that have the issue all C# projects?

I can’t guarantee you that analysis will run without a hitch the first time. But I can tell you that to analyze C# you need to use the scanner that’s specialized for .NET.

 
:woman_shrugging:
Ann

Hi,

Yes, the template is only for .Net C# builds and creating successful and these kinds of builds.

Thanks,
Nikhil

Hi Nikhil,

I’m not sure why you’re succeeding in analyzing C# projects using a different scanner, but I do know that you should be using SonarScanner for .NET for all your C# projects. And I suspect that even for the projects you’re currently able to analyze, you’ll get a better analysis with the correct scanner.

 
Ann

2 posts were merged into an existing topic: Sonarqube 8.9 warning c++ unanalyzed files

Hi Ann,

Do we have a blog/vlog on result comparison of SonarScanner for .NET | SonarQube Docs and scanners before this? This could be a selling point for my team to prepone migration.

Thanks,
Nikhil

Hi Nikhil,

Sorry, but we haven’t put any effort into doing comparisons of what we consider the right way with other ways.

 
:woman_shrugging:
Ann