A chain of If/ElseIf
statements is evaluated from top to bottom. At most, only one branch will be executed: the first statement with a condition that evaluates to
True. Therefore, duplicating a condition leads to unreachable code inside the duplicated condition block. Usually, this is due to a
copy/paste error.
The result of such duplication can lead to unreachable code or even to unexpected behavior.
If param = 1 Then OpenWindow() ElseIf param = 2 Then CloseWindow() ElseIf param = 1 Then ' Noncompliant: condition has already been checked MoveWindowToTheBackground() ' unreachable code End If
If param = 1 Then OpenWindow() ElseIf param = 2 Then CloseWindow() ElseIf param = 3 Then MoveWindowToTheBackground() End If