Getting "The main branch has no lines of code." In a TypeScript Project added With Github

Hi Guys, I have an issue with SonarCloud and a project that was added through GitHub.

  • ALM used (GitHub)
  • CI system used (Sonar Cloud Analyzer BETA)
  • TypeScript
  • It’s a private project.
  • I’m seeing this in the project overview tab even though there is code to analyze:The main branch has no lines of code.
  • I added the project with the steps specified in SonarCloud Portal, nothing more, nothing less.
  • There is no workaround as far as I know, I tried navigating all the views in SonarCloud looking for a way to fix this issue but none of the possible options sounds like it would fix it.
  • I set sonar.sources to my source folder like this sonar.sources=src/I know this worked because now I’m seeing only that folder in the code tab but still the message about the main branch is there and in the code tab it cannot find any LOC (when clearly, there are LOC).
  • I have other TypeScript projects which are working, I don’t see important difference between those and the one that’s not being analyze properly.

Any help is appreciated.


Hello Joseph!

And welcome to the community forum!

Seeing your message I wonder if only a PR of your project gets analyzed ? So you would not see anything on your main branch.
When you go on your project page on SonarCloud, what do you see in this menu :

Do you have a PR that has been analyzed ? If yes that means you will just need to merge it on your main branch to get it analyzed too and all your future PR that you will create from this main branch.

I have a very similar problem and could use a hand. I am trying to get a baseline of my master branch first (i’m measuring this manually via sonar-scanner because it is the first snapshot). As soon as the analysis is committed, it knows about the code, however, the main screen just says “The main branch has no lines of code.” There are no other branches yet on this github repository. Eventually my goal is to use the PR/branch approach as the integration between sonar cloud and github actions take an opinion toward that. But I feel like I need a baseline that sonar sees and can compare against first. Am I wrong?

sonarcloud url:
github repo url:

Is “dependency” a reserved word in sonar where it doesn’t want to analyze a project with that keyword in the project name or project key?

Hello Aaron!

And welcome to the community!

Yeah it’s good to have the target branch for your pull request analyzed first. And it should also be be re-analyzed when you are pushing content to it.

There is no such things as reserved keyword on SonarCloud, any name should work.

Following your link it seems like you were able to fix your issue right ?