sonar-dotnet
sonar-dotnet copied to clipboard
Improve S1192: make threshold inclusive or change default from 3 to 4
Reviewing https://github.com/SonarSource/sonar-dart/pull/40 I noticed the following fact:
Java and C# seem to interpret the definition of the threshold
(Number of times a literal must be duplicated to trigger an issue
) differently:
- Java: "duplicated n" times means "n occurrences" => condition is if
nodes.length >= threshold
(see here) - C#: "duplicated n" times means "n + 1 occurrences (original + duplications)" => condition is if
nodes.length >= threshold
(see here)
C++ doesn't implement S1192 (they most likely have another rule key). I haven't checked other languages. I tend to agree more with the Java (and now Dart) interpretation.
If we want to act on this, and make the interpretation of the parameter (that has the same description in the rspecator for both Java and C#) consistent, and we don't want to increase noise, we should probably change the default from 3 to 4, provided that changing the default doesn't have any other side effect.