rspec/rules/S1968/rule.adoc
2022-02-04 16:28:24 +00:00

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?
// ...
}
}
}
----