Version: SonarQube * Community Edition * Version 9.3 (build 51899)
Rule: S1201 “equals” method overrides should accept “Object” parameters
Code that gives a false positive: (In our case this anonymous inner class was passed as a parameter to a function).
new HashMap<>() {
@Override
public int hashCode() {
return size();
}
@Override
public boolean equals(Object o) {
if (!(o instanceof HashMap)) {
return false;
}
return getOrDefault("id", "").equals(((HashMap) o).get("id"));
}
}