Search code examples
sonarqubesonarqube-web

Different Profiles For Test Module On SonarQube


We have a nice little SonarQube server that evaluates our Maven and Tycho projects. The problem here is that SonarQube uses the same high standards for the integration tests as for the rest of the code.

Which is mostly correct, but it bothers me in the one case: code duplications. Of course production code should have as little duplications as possible, but there seems to be no good alternative in tests.

I tried abstract classes, running tests with @Parameterized and TestSuites, but all of these make the tests hard to understand and maintain.

So the only solution that I think makes sense is for SonarQube to lower its expectations. Yet I couldn't find a way to change the profile of a Maven submodule based on say name or Maven packaging.

How do I solve this problem? Is there a way to change the profile of submodules?


Solution

  • It's not clear here whether you're talking about the Duplications metrics or issues, but the answer to both is Exclusions.

    You can exclude code from the duplications metrics by going to the property's Administration > General Settings > Analysis Scope > Duplications and excluding your modules.

    Similarly, you can exclude that code from the duplications rule at Administration > General Settings > Analysis Scope > Issues