Rules java:S3776 and java:S1541 both deal with complexity of methods, and have similar descriptions. The former, but not the latter, is activated in Sonar way; the latter is on in our QP because we upgraded from older versions of SQ. When I tried activating both in an experiment, the issue count differed by less than 1%, even though the thresholds were different (the default value was used for both).
So should I just replace S1541 with S3776 as the preferred version? As of 8.6, the description of S1541 doesn’t say anything about being replaced, and isn’t deprecated.
Cyclomatic Complexity is about testability - what’s your minimum number of unit tests to exercise all the code? Cognitive Complexity is about understandability.
Today, only the rule using Cognitive Complexity is enabled by default, as we believe it is best suited for the purpose of having clean code.
Still, the rule using Cyclomatic Complexity is available if you need this measure.
OK, thanks for clarifying. They do seem to go together most of the time. For us, close to 90% of the issues for one of the rules are also in the other.