22 lines
486 B
Plaintext
22 lines
486 B
Plaintext
Comparisons of objects of different types are likely programming errors since the comparisons will always return false.
|
|
|
|
|
|
This rule raises an issue when objects with no common ancestor closer than ``++Object++`` are compared.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
[source,text]
|
|
----
|
|
public class MyClass {
|
|
private Mountain mountain = new Mountain("Saint Helens");
|
|
|
|
public doSomething(Apple apple) {
|
|
if (mountain.equals(apple)) { // Noncompliant. Huh?
|
|
// ...
|
|
}
|
|
}
|
|
}
|
|
----
|
|
|