We use sonar cloud for our project code quality analysis. We are facing one problem very frequently now-a-days. When we check in any code, the unit test code analysis for the whole project is being triggered and coming as new code analysis outcome. E.g. I have abc.cs, def.cs, ghi.cs, xyzunittest.cs files in the branch. I updated only abc.cs file and checked in. I see the code analysis has new code smells in xyzunittest.cs. Did you hear about this issue before or have any clue why it might happen?
Versions used (SonarQube, Scanner, Plugin, and any relevant extension)
We use Sonarcloud. Azure DevOps Task (Scanner and Analysis) versions: 4
Error observed (wrap logs/code around triple quote ``` for proper formatting)
Steps to reproduce: Trigger one sonar cloud build
Potential workaround: exclude the unit test files from analysis
Scanner command used when applicable (private details masked)
sonar.exclusions=/AssemblyInfo.cs
sonar.test.exclusions=/AssemblyInfo.cs
sonar.cs.vstest.reportsPaths=$(BUILD.SOURCESDIRECTORY)\Sources\TestResults**\TestResults*.trx
It’s a bit hard to understand the problem from your description. How about some screenshots, or a public sample project on SonarCloud that display the issue?
Is your Unit Test Project (where xyzunittest.cs is located) being categorized as a Test Project? You can read more about what that means (and how to tell) here.
It should be categorized as test project because the project name has ‘UnitTests’ in it. But can it cause reappearing of old code smells? Can it be solved by adding below line in the project itself? So we need to add it for all the unit test projects, right?
SonarQubeTestProject => true
I was not aware that this is just a forum. We are a paid customer of SonarCloud and they asked us to post the query here. I was expecting some follow ups. Thanks for helping me out btw! I will try to get the logs.