Comparisons of dissimilar types will always return false
. The comparison and all its dependent code can simply be removed. This
includes:
- comparing an object with
null
- comparing an object with an unrelated primitive (e.g. a
String
with an int
)
- comparing unrelated types
Noncompliant code example
void f() {
var a = "Hello, World!";
if (a == 42) { // Noncompliant: comparing a String with an int
print("BOOM!");
}
}