COV.CMP

Error exists when method compareTo declared with signature different than int compareTo(Object).

Vulnerability and risk

Intent was probably to implement interface method of Comparable interface, but since this method has different signature it is not same method and will not be called when comparator is used.

Mitigation and prevention

Declare that class implements Comparable, declare int compareTo(Object) method.

Example 1

Copy
         String name;
         int compareTo(MyClass a) {
             return name.compareTo(a.name);
         }

COV.CMP is reported for line 15: Method compareTo(..) should have signature 'public int compareTo(Object)'