Skip to main content

RCS1218: Simplify code branching

Properties

PropertyValue
Default SeverityInfo
Minimum language version-

Examples

Example #1

diagnostic.cs
if (x)
{
}
else
{
M();
}
fix.cs
if (!x)
{
M();
}

Example #2

diagnostic.cs
while (true)
{
if (x)
{
M();
}
else
{
break;
}
}
fix.cs
while (x)
{
M();
}

Example #3

diagnostic.cs
while (true)
{
if (x)
{
break;
}

M();
}
fix.cs
while (!x)
{
M();

}

Example #4

diagnostic.cs
do
{
M();

if (x)
{
break;
}

} while (true);
fix.cs
do
{
M();

} while (!x);

Example #5

diagnostic.cs
if (x)
{
do
{
M();
}
while (x);
fix.cs
while (x)
{
M();
}

Applies to