"main" branch has not been analyzed yet and you have multiple branches already. It looks like it is

  • ALM used: GitHub
  • CI system used: Teamcity
  • Scanner command used when applicable (private details masked):
  • Languages of the repository: Typescript/Javascript

Hi everyone,

I’m experiencing an issue with main branch analysis that’s only affecting one of my repositories, while others with identical configurations work fine.

Problem:

  • Getting error: “Main branch has not been analyzed yet, and you have multiple branches already. It looks like it is not your main branch. Check your configuration.”

  • This only happens with one specific repository

  • Other repositories with the same setup work correctly

Setup:

  • Using @sonar/scan npm package
  • Triggering scans after pushing to main branch
npx @sonar/scan \
	-Dsonar.token=%SONAR_TOKEN% \
	-Dsonar.branch.name=main \
	-Dsonar.verbose=true
  • Configuration is identical across all repositories

What I’ve Verified:

  • In the SonarQube Branches tab, “main” is correctly set as the main branch

  • Build logs confirm the branch being scanned is named “main” (See attached log file)

  • redacted_logs.txt (24.6 KB)

  • Configuration matches working repositories exactly

Has anyone encountered this issue where identical configurations work for some repos but not others? Any suggestions on what might be causing this inconsistency would be greatly appreciated.

Thanks in advance for your help!

Hey there.

2 questions!

  • When you click on the Code tab, do you see any file structure?
  • In your logs, you should see some information like the below:
10:53:58.663 INFO  3 languages detected in 22 preprocessed files (done) | time=121ms
10:53:58.663 INFO  0 files ignored because of inclusion/exclusion patterns
10:53:58.663 INFO  141 files ignored because of scm ignore settings
10:53:58.710 INFO  Loading plugins for detected languages
10:53:58.710 DEBUG Detected languages: [py, json, yaml]
10:53:58.710 INFO  Load/download plugins
10:53:58.763 INFO  Load/download plugins (done) | time=52ms
10:53:58.763 DEBUG Optional language-specific plugins not loaded: [abap, sonarapex, architecturejavascriptfrontend, architecturejavafrontend, csharpenterprise, cpp, cobol, dart, dbdjavafrontend, flex, go, web, jcl, javasymbolicexecution, java, kotlin, php, pli, plsql, rpg, ruby, rust, sonarscala, jasmin, swift, tsql, vbnetenterprise, vb, securitycsharpfrontend, securitygofrontend, securityjavafrontend, securitykotlinfrontend, securityphpfrontend, securityvbnetfrontend, xml]
10:53:58.804 DEBUG Plugins loaded:
10:53:58.804 DEBUG   * Python Enterprise Code Quality and Security 5.10.0.25429 (python)
10:53:58.804 DEBUG   * Vulnerability Analysis 11.10.0.40378 (security)
10:53:58.804 DEBUG   * Vulnerability Rules for JS 11.10.0.40378 (securityjsfrontend)
10:53:58.804 DEBUG   * Vulnerability Rules for Python 11.10.0.40378 (securitypythonfrontend)
10:53:58.804 DEBUG   * Dataflow Bug Detection Rules for Python 2.2.1.17653 (dbdpythonfrontend)
10:53:58.804 DEBUG   * Dataflow Bug Detection 2.2.1.17653 (dbd)
10:53:58.804 DEBUG   * JavaScript/TypeScript/CSS Code Quality and Security 11.4.1.34873 (javascript)
10:53:58.804 DEBUG   * Architecture Analysis 2.3.0.6597 (architecture)

It looks like you may have redacted this. Can you share it?