Conditional expressions which are always true or false can lead to unreachable code.
In the case below, the call of Dispose() never happens.
Dim a = False
If a Then
Dispose() ' Never reached
End If
Exceptions
This rule will not raise an issue in either of these cases:
- When the condition is a single
const bool
Const debug = False
'...
If debug Then
' Print something
End If
- When the condition is the literal
true or false.
In these cases, it is obvious the code is as intended.