Hello!
I believe I found a bug causing overridden equals methods not being recognized by sonar, when the overridden equals is declared as final.
-
Versions used:
SonarQube: 7.2 (build 13530)
maven scanner: 3.4.1.1168 -
Error observed:
SonarQube says to ‘Override the “equals” method in this class.’, but the method is overridden -
Code example:
import java.util.Objects; public abstract class A { private int field; @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof A)) return false; A a = (A)o; return field == a.field; } } public class B extends A { private String name; @Override public final boolean equals(Object o) { if (this == o) return true; if (!(o instanceof B)) return false; if (!super.equals(o)) return false; B b = (B)o; return Objects.equals(name, b.name); } }
-
Screenshot of the message:
Thanks!