Squid:S2583: Java : Conditionally executed blocks should be reachable
So if there is a block of code that is not reachable means it is a dead code and that piece of code should be removed.
Noncompliant Code Example
a = false;
if (a) { // Noncompliant
doSomething(); // never executed
}
if (!a || b) { // Noncompliant; "!a" is always "true", "b" is never evaluated
doSomething();
} else {
doSomethingElse(); // never executed
}
Non Compilant Code Real Example
public synchronized boolean equals(java.lang.Object obj) {
if (!(obj instanceof ControlledOrg)) return false;
ControlledOrg other = (ControlledOrg) obj;
if (obj == null) return false;
if (this == obj) return true;
if (__equalsCalc != null) {
return (__equalsCalc == obj);
}
in the above code
obj==null --> return false that is unreachable code since obj is checked as the instance of ControlledOrg and it will do the null check there so there is no point of checking it again