Skip to main content

RCS1208: Reduce 'if' nesting

Properties​

PropertyValue
Default Severitydisabled by default
Minimum language version-

Examples​

Example #1​

diagnostic.cs
if (condition1)
{
Foo1();

if (condition2)
{
Foo2();

if (condition3)
{
Foo3();
}
}
}
fix.cs
if (!condition1)
{
return;
}

Foo1();

if (!condition2)
{
return;
}

Foo2();

if (!condition3)
{
return;
}

Foo3();

Applies to​