Scanning of Pull requests are not happening [BLOCKING]

I am struggling setting up SONAR Cloud in my project. I have the SONAR Cloud subscription.
I have many problems using it.

  1. When I push code in any branch - SONAR starts the merge request analysis and run successfully but at the end dashboard is shown all ZEROs. Please check the screen shot.
  2. If I specify the branch name in the sonar project property file then it is able to analyse and show some results but then - It is not handy to hard code branch name in the property file.
  3. Once branch analysis is done - (after specifying a specific branch name in property file) - I see Test Coverage is Zero while there are so many Unit tests are written.

Screenshot 2021-06-03 at 10.04.05

HI @vishwa007, welcome to the community,

Could you please share with us:

  • the CI you use
  • the language(s) of your project
  • the pipeline file or the command used to run the Sonar Scanner
  • the logs produced during the Sonar Scanner analysis

Hi @Claire_Villard

Here are the answers to all the questions you asked for:

  1. CI. - GitLab CI is used
  2. JavaScript/TypeScript and PHP ( tried on all 3 projects)
  3. Following command is setup in the Pipeline Stage:
      stage: Sonarcloud Scan
        name: sonarsource/sonar-scanner-cli:latest
        entrypoint: [""]
        key: "${CI_JOB_NAME}"
          - .sonar/cache
        - sonar-scanner -Dsonar.qualitygate.wait=true
          when: always
          allow_failure: true```

Following is setup in Sonar Project propery file:
# This is the name and version displayed in the SonarCloud UI.

# Path is relative to the file. Replace "\" by "/" on Windows.
  1. Log has got many confidential information. Let me know how can I arrange this?

Note: In the first screenshot, if you see every KPI is zero except one - Code duplication. That is always calculated. How is that possible.

the question is also which files have changed. The Pull Request/Merge Request view will only show you changes based on the files you changed.

If you do not change source files, there will not be coverage in the PR overview. see also

Try to add some source code changes and see if this changes something with your code :slight_smile:

1 Like

Hi @simon.schrottner @Claire_Villard ,

Thanks for the response. For any PR requests, I am able to see the analysis on all the lines of changes done.
But we do not see analysis of overall branch. How can we achieve that? We are expecting something like this - where I can see analysis of a specific PR and also overall analysis of that branch. Something like this: We get this when we are running Sonar analysis in my local in docker:

  1. Also We do not know how to setup this following setting which is related to “New Code” definition.

  2. So how can I analyse the whole branch whenever there is a pull request created?

About 1. and 3.
Overall analysis does not exist for Pull Requests. All code updated in a Pull Request is considered as new code. SonarCloud philosophy is to clean the code while coding, meaning all the new code should be clean, but fixing all the code that already works would be a difficult work. You can find more information on this on that page.
To have overall analysis on a given branch, you should not analyze it as a Pull Request but as a Long living branch. Here is the documentation to configure the Long living branch pattern.

Have you read the New code definition dedicated page? To help you further on that configuration, I would need to know the kind of release management to have on your project: version based, continuous delivery, other…


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