First analysis on feature branch

Hi,
ALM: Azure DevOps
CI: Azure DevOps

i have a question regarding the setup of SonarCloud for existing projects.
In my project, we are not allowed to directly push to master or develop, only via pull requests.
Therefore, the initial setup of SonarCloud needs to happen within a newly created feature branch.
However, creating a pull request always leads to all code-smells and bugs to appear in the pull request annotation as no analysis of the default branch happened before. Therefore, all bugs and code-smells are “new” in the feature branch.

However, running the scanner locally to create a first analysis does not always work for me. Is there an alternative?

Best regards,
Sebastian

Hi @Sebastian1

It is expected that on the very first ‘setting up’ PR all issues appear as ‘new’.

The steps to set up the analysis are:

  1. Set up the scan, and check that issues are reported and that decoration on the PR works. Reported issues are proof that the scan works, just ignore them at this point. Do not block the merge on the quality gate state at this stage.
  2. Merge the PR. This should trigger analysis on the main branch
  3. Configure the ‘new code’ period to get a quality gate on the main branch, if not done before
  4. Now all new PRs should have only really new issues
  5. If you want, you can block the merges to the main branch depending on the quality gate status

Hope that helps,
Anita