Skip to content

Latest commit

 

History

History
140 lines (105 loc) · 1.16 KB

RCS1218.md

File metadata and controls

140 lines (105 loc) · 1.16 KB

RCS1218: Simplify code branching

Property Value
Id RCS1218
Category Readability
Severity Info

Examples

Code with Diagnostic

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

Code with Fix

if (!x)
{
  M();
}

Code with Diagnostic

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

Code with Fix

while (x)
{
  M();
}

Code with Diagnostic

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

  M();
}

Code with Fix

while (!x)
{
  M();
      
}

Code with Diagnostic

do
{
  M();

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

Code with Fix

do
{
  M();

} while (!x);

Code with Diagnostic

if (x)
{
  do
  {
    M();
  }
  while (x);

Code with Fix

while (x)
{
  M();
}

See Also

(Generated with DotMarkdown)