sonar-dotnet
sonar-dotnet copied to clipboard
Fix S1871 FN: Nested `if .. else if` chain
if (s == 0)
{
DoSomething1();
}
else
{
if (s > 0 && s < 11)
{ // FN
DoSomething1();
}
else
{
if (s > 11 && s < 20)
{ // FN
DoSomething1();
}
else
{
DoSomething2();
}
}
}
Is semantically the same as:
if (s == 0)
{
DoSomething1();
}
else if (s > 0 && s < 11)
{ // Noncompliant
DoSomething1();
}
else if (s > 11 && s < 20)
{ // Noncompliant
DoSomething1();
}
else
{
DoSomething2();
}