Disable specific rules for test files in gradle projects

SonarQube 9.6.1.59531 and sonarqube gradle plugin 3.4.0.2513

What are you trying to achieve:
In our code we have unit tests that use kotest and behaviorspec. This results in given, when, then clause duplication. And sonarqube marks those places as code smells. What I want to do is exclude duplicate rule for files that contain Test suffix in name. Is it possible? If not, what would be recommended approach?
What have you tried so far to achieve this:
I tried excluding all test files with mixed results, but I didn’t found a way to exclude rules per file types.

Hi,

Are your test files included in your sonar.sources definition? If so, straightening that out would automatically mean most normal rules weren’t run on those files. But barring that, you could set a multi-critera exclusion.

 
HTH,
Ann

@ganncamp , thank you. Multi criteria exclusion section helped.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.