Not getting any results - The main branch has no lines of code

  • ALM used - Bitbucket Cloud
  • CI system used - Bitbucket Cloud
  • Scanner command used when applicable:

script:
- pipe: sonarsource/sonarcloud-scan:1.2.0
- pipe: sonarsource/sonarcloud-quality-gate:0.1.4

  • Languages of the repository - monorepo but these files are typescript
  • Error observed:

The main branch has no lines of code.

Quality gate has not been computed for project.

  • Steps to reproduce: Running any scan pipeline, it finishes successfully but when I click the task report I get the branch has no code, running the quality gate pipe fails saying the quality gate has not been computed.

Example task id: AXewAeidEWiiWykwLLk_

Hello @Matt12, welcome to the community forum and apologies for the late reply.

The error message the main branch has no lines of code indicates that your default branch hasn’t been analyzed yet. Could it be that you currently are only analyzing PRs and non default branches?

It would also be good to check that the default branch on SonarCloud is the same as on Bitbucket Cloud. You can do this by navigating to you
project on SonarCloud and Administration > Branches & Pull Request. You can rename the default branch on SonarCloud to match your default branch on Bitbucket Cloud.

1 Like

Same Error “The main branch has no lines of code.” when I scan my xcode project with Fastlane. Please help and if possible provide a well define tutorial how we scan iOS code with sonar through Fastlane.

Has anybody ever fixed this? I am having the same problem with GitLab. I’ve double checked my .gitlab file and it’s checking all the branches including my default branch and still it says “The main branch has no lines of code.” but when I define my own quality gate rules it will fail because of the errors I have purposely implemented but it still won’t give me any results on the overview tab. It just continues to say “The main branch has no lines of code.”

2 Likes

Same issue in gitlab, I see the code, but still says ‘The main branch has no lines of code’. Any help?

Disabling the SCM helped me resolve this issue in some cases. You either do it by passing sonar.scm.disabled=true or go to project settings → general settings → SCM → Disable SCM

After disabling the SCM , Its not showing the SCM directory under overview and not scanning the java code inside my app folder from gitlab

I ended up in same issue , But for other projects its scanning well and showing the results. We are having snapshots for java and its not showing any code in overview and also not showing any scanned results