Why is this an issue?

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.

How to fix it

Code examples

Noncompliant code example

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

Compliant solution

If param = 1 Then
  OpenWindow()
ElseIf param = 2 Then
  CloseWindow()
ElseIf param = 3 Then
  MoveWindowToTheBackground()
End If

Resources

Documentation