Permalink
Fetching contributors…
Cannot retrieve contributors at this time
63 lines (46 sloc) 923 Bytes

RCS1208: Reduce if nesting

Property Value
Id RCS1208
Category Style
Default Severity Info
Enabled by Default -
Supports Fade-Out -
Supports Fade-Out Analyzer -

Example

Code with Diagnostic

if (condition1) // RCS1208
{
    Foo1();

    if (condition2)
    {
        Foo2();

        if (condition3)
        {
            Foo3();
        }
    }
}

Code with Fix

if (!condition1)
{
    return;
}

Foo1();

if (!condition2)
{
    return;
}

Foo2();

if (!condition3)
{
    return;
}

Foo3();

See Also

(Generated with DotMarkdown)