Back to Devexpress

CRR0008 - If-block matches else-block

coderushforroslyn-118106-static-code-analysis-analyzers-library-crr0008-if-block-matches-else-block.md

latest713 B
Original Source

CRR0008 - If-block matches else-block

  • Feb 28, 2025

This analyzer detects if - else conditional statements with similar code in both branches.

csharp
if (condition) // CRR0008
    DoSomething();
else
    DoSomething();
vb
If condition Then ' CRR0008
    DoSomething()
Else
    DoSomething()
End If

Such statements are redundant because the condition value does not change the execution result. Consider modifying one of the branches or deleting the conditional statement along with one branch.

See Also

Suppress Analyzers