org.sonar.l10n.java.rules.squid.S1850.html Maven / Gradle / Ivy
The newest version!
instanceof
operators that always return true
or false
are either useless or the result of a misunderstanding which could lead to unexpected behavior in production.
Noncompliant Code Example
public boolean isSuitable(Integer param) {
...
if(param instanceof Number) { //Always true as param is an Integer, unless param is null
doSomething();
}
...
}
Compliant Solution
public boolean isSuitable(Integer param) {
...
doSomething();
...
}
See
- MITRE, CWE-571 - Expression is Always True
- MITRE, CWE-570 - Expression is Always False
© 2015 - 2025 Weber Informatics LLC | Privacy Policy