rspec/rules/S1968/rule.adoc

24 lines
513 B
Plaintext

== Why is this an issue?
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?
// ...
}
}
}
----