All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.plugins.csharp.S1227.html Maven / Gradle / Ivy

There is a newer version: 10.2.0.105762
Show newest version

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