Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve S1192: make threshold inclusive or change default from 3 to 4 #9647

Open
antonioaversa opened this issue Aug 14, 2024 · 0 comments
Open
Labels
Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. Type: False Positive Rule IS triggered when it shouldn't be.

Comments

@antonioaversa
Copy link
Contributor

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.

@antonioaversa antonioaversa added Area: VB.NET VB.NET rules related issues. Area: C# C# rules related issues. Type: Rule rework Change rule behavior labels Aug 14, 2024
@costin-zaharia-sonarsource costin-zaharia-sonarsource added Type: False Positive Rule IS triggered when it shouldn't be. and removed Type: Rule rework Change rule behavior labels Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. Type: False Positive Rule IS triggered when it shouldn't be.
Projects
None yet
Development

No branches or pull requests

2 participants