Conditional expressions which are always true
or false
can lead to dead code. Such code is always buggy and should never
be used in production.
Noncompliant Code Example
a = False
if a: # Noncompliant
doSomething() # never executed
n = None
if not n: # Noncompliant; n is None, which is always equivalent to "False" in a condition, "doSomethingElse()" is never evaluated
doSomething()
else:
doSomethingElse() # never executed
See