Permalink
Fetching contributors…
Cannot retrieve contributors at this time
120 lines (90 sloc) 1.26 KB

RCS1218: Simplify code branching

Property Value
Id RCS1218
Category Readability
Default Severity Info
Enabled by Default
Supports Fade-Out -
Supports Fade-Out Analyzer -

Examples

Code with Diagnostic

if (x) // RCS1218
{
}
else
{
  Foo();
}

Code with Fix

if (!x)
{
  Foo();
}

Code with Diagnostic

while (true)
{
  if (x)  // RCS1218
  {
    Foo();
  }
  else
  {
    break;
  }
}

Code with Fix

while (x)
{
  Foo();
}

Code with Diagnostic

while (true)
{
  if (x)  // RCS1218
  {
    break;
  }

  Foo();
}

Code with Fix

while (!x)
{
  Foo();
      
}

Code with Diagnostic

do
{
  Foo();

  if (x)  // RCS1218
  {
    break;
  }
  
} while (true)

Code with Fix

do
{
  Foo();

} while (!x)

See Also

(Generated with DotMarkdown)