One PR with multiple Sonar projects: PR decoration are erased by the last sonar analysis

Hello,

My configuration is the following:

  • Sonarcloud + Azure Devops
  • 1 Repository
  • 2 .Net solutions: Solution A & B
  • 2 Sonarcloud projects one for each .net solution: project A & B respectively for solution A & B
  • 2 Azure devops builds with sonar analysis, one for each .net solution

My issue: the PR is decorated only by the analysis of the last executed sonar project out of the two.
For instance:

  1. Project A analysis: issue 1 & 2
  2. Project B analysis: issue 3
  3. Lets assume project B analysis is completed after project A ones
  4. ==> Issue: the PR is decorated only by project B analysis and contains only issue 3

Thanks for your help.

2 Likes

Hello,

When a PR is decorated, existing issue are deleted and replaced by issues from the new analysis. There is currently no workaround for this.

I am not familiar with .Net so I don’t know what a ‘solution’ is, but I guess having only one project instead of 2 is not possible?

Benoît

Thank you for your prompt reply.

Solution A: desktop application
Solution B: rest api used by the desktop application

Each solution is a set of .net projects.

Having one sonar project is also a solution but we needs to reconsider the CI jobs for 10 teams. I wanted to be sure that this behavior is a limitation/design issue and not a miss-configuration of sonar tools.

Mounsif.

We are experiencing the same issue. Will there be any fix for this anytime soon?

If I understand correctly, in a single repository, you have multiple SonarCloud projects. For each PR in this repository, you run SonarCloud analysis for each project. As such the same PR is shared by multiple SonarCloud projects.

The PR decoration feature was designed with a 1-to-1 mapping in mind between SonarCloud and a repository. Supporting the many-to-1 scenario you describe is not planned for the near future. I’ll raise this point internally.

1 Like

Hi, thank you for the swift reply. Indeed, we have multiple Sonarcloud projects in one repo. It could be that a PR hits multiple projects, causing multiple Sonarcloud analysis to take place.

To me it seems like Sonarcloud is currently removing all comments before placing new ones after an analysis. So when multiple projects run, only the last analysis is contained. Would it be possible to disable the removal step and have people mark items as ‘Resolved’ (in Azure DevOps) manually? I think that would not only solve the issue, but also helps to make transparent which issues where there and how they were fixed.

It’s not that simple. What if another analysis runs that contains a sub-set of the issues from a previous run? Existing issues would have to be matched with the latest run to avoid creating duplicates.

I found another thread for the scenario we’re discussing here. So this issue is clearly on our radars, let’s continue the discussion there.