C#

C#

By DeepSource

if conditions can be merged CS-R1039

Anti-pattern

Nested if conditions can be merged together into a single condition. This can help improve code readability in complex codebases and reduce indentation level.

Examples

Bad Practice

if (condition1)
{
    if (condition2)
    {
        if (condition3)
        {
            // ...
        }
    }
}

Recommended

if (condition1 && condition2 && condition3)
{
    // ...
}