Quality Gate: support unit test coverage with cyclomatic complexity filter

In many cases we want to focus on the complex code other than simple code like setters/getters. Unit test coverage tools like JaCoco has built-in support for cyclomatic complexity. We hope sonar quality gate can filter out those simple codes (e,g. cyclomatic complexity below a certain configurable score).
Currently we can only filter out a whole module in build script, there is no fine-grained automatic way to do that.

Hello @DanielYWoo,

Here is what I understood from your request, please tell me if I’m correct.

You want to be able to configure SonarQube to not expect “methods/functions with a complexity lower than x” to be covered. It would mean that if a method is having a complexity lower than x and the method is fully covered, this coverage won’t participate to the overall coverage metric. It would be similar to: the method doesn’t exist from a coverage perspective.

Is that correct?

Thanks
Alex

Yes, that’s right.
Unit test tools like JaCoCo can output all the information including the cyclomatic complexity score, so SonarQube should be able to do that.