org.sonar.plugins.csharp.S1227.html Maven / Gradle / Ivy
Why is this an issue?
break;
is an unstructured control flow statement which makes code harder to read.
Ideally, every loop should have a single termination condition.
Noncompliant code example
int i = 0;
while (true)
{
if (i == 10)
{
break; // Non-Compliant
}
Console.WriteLine(i);
i++;
}
Compliant solution
int i = 0;
while (i != 10) // Compliant
{
Console.WriteLine(i);
i++;
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy