Pull Request analysis shows 0 lines of code

Hey,

Sory for the late reply.

Could you execute a git diff before running scanner analysis like git diff <sonar.pullrequest.base> < sonar.pullrequest.branch > and share if there are any line changes detected?

Thanks for the response. here is the git diff you requested. I have hidden other parts for privacy reasons.

Hey @jacek.poreda
I wanted to follow up. Were you able to review the git diff i sent?

Hey @Venkatesh_Ragavan ,

Thanks for the diff, though could you confirm that you have used local refs of the branches and they are up to date?

Can you confirm that those two parameters -Dsonar.pullrequest.base=xxx -Dsonar.pullrequest.branch=xxx are having correct branches? Where sonar.pullrequest.base should be your main branch and sonar.pullrequest.branch should be a branch which supposed to be a PR branch?

You mentioned that you have changed two files, though analysis detected 5 files, is there any other files there?

Does this occur to any other branch?

Hey Jacek,

These are the only 2 file changes that are being made. I can also confirm that the 2 params have the correct values.

@Venkatesh_Ragavan , you did not reply to all my questions.

could you confirm that you have used local refs of the branches and they are up to date?

Does this occur to any other branch/PR?

Q1) Yes
Q2) Yes, it happens to another PR but of the same branch

Hi @Venkatesh_Ragavan.

Can you provide the branch names (or some alias) so it is easier to refer to them other than “this branch” and “other branch”? :slight_smile:

This means that it is exactly the same command; you are not trying with different branches, which means the result will be the same. What happens if you try another branch combination?

Is this happening with another developer in your team? Is this happening in another project?

Hey Davi,
The base branch is “master” and this problems happens in the feature branch , lets say, branch-v1, and another feature branch, branch-v2. Both branch-v1 and branch-v2 's base branch is the master.

Hey Davi,

Is it possible to schedule a call at your earliest convenience? I have had a lot of one-one exchanges in the forum and a resolution is yet to be found. This issue is of time sensitive and private nature. Hence, it would be very beneficial for us to get in a call so that I can provide all information needed in one go and be a lot more specific. Let me know if it’s possible

Hi @Venkatesh_Ragavan.

In this case, as per our FAQ, I will point you to our commercial support.

2 Likes

@Venkatesh_Ragavan

I tried to reproduce your problem, but in my case, everything seems to be working fine.

I followed these steps:

  1. Analyze the main branch by executing sonar-scanner -Dsonar.organization=xxx -Dsonar.projectKey=xxx -Dsonar.token=xxx

  2. Created a new branch called pr-1, did some changes executed a command similar to yours sonar-scanner -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=xxx -Dsonar.projectKey=xxx -Dsonar.token=xxx -Dsonar.pullrequest.key=1 -Dsonar.pullrequest.base=main -Dsonar.pullrequest.branch=pr-1 -Dsonar.scm.provider=git

  3. The results appear correctly in SonarCloud UI

Can you confirm you did the same steps?

Hey Jacek,
those were the steps. But surprisingly, I tried them again and it works for PR Analysis. However i am doing the following for a full branch analysis,


sonar-scanner \
  -Dsonar.organization=xxx \
  -Dsonar.projectKey=xxxx \
  -Dsonar.sources=xxxi \
  -Dsonar.host.url=https://sonarcloud.io \
  -Dsonar.exclusions=**/node_modules/**/*  \
  -Dsonar.token=xxx \
  -Dsonar.c.file.suffixes=- \
  -Dsonar.cpp.file.suffixes=- \
  -Dsonar.scm.provider=git \
  -Dsonar.pullrequest.name= <branch_name>

The analysis is happening and it asks me to check the dashboard but there is no sign of the analysis in the dashboard. am i doing the full branch analysis correctly?

@Venkatesh_Ragavan if you are analyzing the main branch you don’t need to specify -Dsonar.pullrequest.name= <branch_name>, you are interested in the following parameters:

  • sonar.branch.name = branch-1
  • sonar.branch.target = main

Please read carefully over this documentation. It explains how to analyze a project without an integrated environment.

1 Like

Hey Jacek,
Thanks for the response. It worked. I have another Q. Does SonarCloud offer the ability to run analysis by making requests to sonarCloud API?

I think you are referring to automatic analysis, you can check the details here

Also if your problem has been resolved I’m closing this topic. Please open a new one if you have different questions/issues.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.