A solution I’m analysing in SonarCloud via Azure Pipelines is showing code smells in the test projects. I would like to prevent code smells in test projects being analysed but I can’t seem to prevent it.
I tried sonar.exclusions to add the test project but they weren’t excluded and I don’t know if this is the correct approach anyway.
Please see image. Any assistance would be appreciated.
Your idea of using exclusions seems to right one to me, except that to exclude test files, you should use the sonar.test.exclusions property instead of sonar.exclusions.
It should remove all the issues found in the files matching the exclusion pattern.
More information about narrowing the analysis scope is available here.
If you would like to remove only some of them because they are not relevant for you, you can also disable the rules generating those issues in your Quality Profile definition.
Documentation about quality profiles is here.