Hello,
we are using sonarqube to check our code and normaly try to not avoid code duplications. However in this one case sonarqube detects a code duplication even though the code is clearly not duplicated.
- Used SonarQube version: Enterprise Edition - Version 9.9 (build 65466)
In the specific case we have the poles of a bessel filter defined in code:
switch (filterOrder)
{
case 1:
poles.Add(new Complex(-1.0, 0.0));
return true;
case 2:
poles.Add(new Complex(-0.8660254037844388, 0.5));
poles.Add(new Complex(-0.8660254037844388, -0.5));
return true;
case 3:
poles.Add(new Complex(-0.7456403858480766, 0.7113666249728346));
poles.Add(new Complex(-0.7456403858480766, -0.7113666249728346));
poles.Add(new Complex(-0.9416000265332054, 0.0));
return true;
case 4:
poles.Add(new Complex(-0.6572111716718838, 0.8301614350048729));
poles.Add(new Complex(-0.6572111716718838, -0.8301614350048729));
poles.Add(new Complex(-0.904758796788244, 0.2709187330038754));
poles.Add(new Complex(-0.904758796788244, -0.2709187330038754));
return true;
case 6:
poles.Add(new Complex(-0.5385526816693076, 0.9616876881954238));
poles.Add(new Complex(-0.5385526816693076, -0.9616876881954238));
poles.Add(new Complex(-0.7996541858328181, 0.5621717346937415));
poles.Add(new Complex(-0.7996541858328181, -0.5621717346937415));
poles.Add(new Complex(-0.9093906830472419, 0.1856964396792985));
poles.Add(new Complex(-0.9093906830472419, -0.1856964396792985));
return true;
case 8:
poles.Add(new Complex(-0.46217404125320455, 1.0343886811269039));
poles.Add(new Complex(-0.46217404125320455, -1.0343886811269039));
poles.Add(new Complex(-0.7111381808485344, 0.7186517314108379));
poles.Add(new Complex(-0.7111381808485344, -0.7186517314108379));
poles.Add(new Complex(-0.8473250802359428, 0.42590175382729417));
poles.Add(new Complex(-0.8473250802359428, -0.42590175382729417));
poles.Add(new Complex(-0.9096831546652927, 0.1412437976671126));
poles.Add(new Complex(-0.9096831546652927, -0.1412437976671126));
return true;
default:
poles = null;
return false;
}
This would lead to Sonarqube detecting Case 4,6 and 8 as duplicated blocks:
Is that a bug or is it related to the compley values being very similar. How could we avoid this being detected as duplicate?