Parcourir la source

Error Prone: Increase severity of NonOverridingEquals to ERROR

Error Prone reports the warning on several classes:

   [NonOverridingEquals] equals method doesn't override Object.equals;
   if this is a type-specific helper for a method that does override
   Object.equals, either inline it into the callers or rename it to
   avoid ambiguity.

   See https://errorprone.info/bugpattern/NonOverridingEquals

Most of these are in the public API, so we can't rename or inline them
without breaking the API. FileSnapshot is not part of the public API,
but clients may be using it anyway, so we also shouldn't change that.

Suppress all the warnings instead. Having the check at severity ERROR
will at least make sure we don't introduce any new occurrences.

Change-Id: I92345c11256f06b4fa03ccc13337f72af5a43591
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
tags/v5.4.1.201908211225-r
David Pursehouse il y a 4 ans
Parent
révision
430be89307

+ 1
- 0
org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/AnyLongObjectId.java Voir le fichier

@@ -274,6 +274,7 @@ public abstract class AnyLongObjectId implements Comparable<AnyLongObjectId> {
* the other id to compare to. May be null.
* @return true only if both LongObjectIds have identical bits.
*/
@SuppressWarnings("NonOverridingEquals")
public final boolean equals(AnyLongObjectId other) {
return other != null ? equals(this, other) : false;
}

+ 1
- 0
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java Voir le fichier

@@ -317,6 +317,7 @@ public class FileSnapshot {
* the other snapshot.
* @return true if the two snapshots share the same information.
*/
@SuppressWarnings("NonOverridingEquals")
public boolean equals(FileSnapshot other) {
return lastModified == other.lastModified && size == other.size
&& Objects.equals(fileKey, other.fileKey);

+ 1
- 0
org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java Voir le fichier

@@ -276,6 +276,7 @@ public abstract class AnyObjectId implements Comparable<AnyObjectId> {
* the other id to compare to. May be null.
* @return true only if both ObjectIds have identical bits.
*/
@SuppressWarnings("NonOverridingEquals")
public final boolean equals(AnyObjectId other) {
return other != null ? equals(this, other) : false;
}

+ 8
- 0
org.eclipse.jgit/src/org/eclipse/jgit/lib/FileMode.java Voir le fichier

@@ -88,6 +88,7 @@ public abstract class FileMode {
public static final FileMode TREE = new FileMode(TYPE_TREE,
Constants.OBJ_TREE) {
@Override
@SuppressWarnings("NonOverridingEquals")
public boolean equals(int modeBits) {
return (modeBits & TYPE_MASK) == TYPE_TREE;
}
@@ -97,6 +98,7 @@ public abstract class FileMode {
public static final FileMode SYMLINK = new FileMode(TYPE_SYMLINK,
Constants.OBJ_BLOB) {
@Override
@SuppressWarnings("NonOverridingEquals")
public boolean equals(int modeBits) {
return (modeBits & TYPE_MASK) == TYPE_SYMLINK;
}
@@ -106,6 +108,7 @@ public abstract class FileMode {
public static final FileMode REGULAR_FILE = new FileMode(0100644,
Constants.OBJ_BLOB) {
@Override
@SuppressWarnings("NonOverridingEquals")
public boolean equals(int modeBits) {
return (modeBits & TYPE_MASK) == TYPE_FILE && (modeBits & 0111) == 0;
}
@@ -115,6 +118,7 @@ public abstract class FileMode {
public static final FileMode EXECUTABLE_FILE = new FileMode(0100755,
Constants.OBJ_BLOB) {
@Override
@SuppressWarnings("NonOverridingEquals")
public boolean equals(int modeBits) {
return (modeBits & TYPE_MASK) == TYPE_FILE && (modeBits & 0111) != 0;
}
@@ -124,6 +128,7 @@ public abstract class FileMode {
public static final FileMode GITLINK = new FileMode(TYPE_GITLINK,
Constants.OBJ_COMMIT) {
@Override
@SuppressWarnings("NonOverridingEquals")
public boolean equals(int modeBits) {
return (modeBits & TYPE_MASK) == TYPE_GITLINK;
}
@@ -133,6 +138,7 @@ public abstract class FileMode {
public static final FileMode MISSING = new FileMode(TYPE_MISSING,
Constants.OBJ_BAD) {
@Override
@SuppressWarnings("NonOverridingEquals")
public boolean equals(int modeBits) {
return modeBits == 0;
}
@@ -165,6 +171,7 @@ public abstract class FileMode {

return new FileMode(bits, Constants.OBJ_BAD) {
@Override
@SuppressWarnings("NonOverridingEquals")
public boolean equals(int a) {
return bits == a;
}
@@ -206,6 +213,7 @@ public abstract class FileMode {
* a int.
* @return true if the mode bits represent the same mode as this object
*/
@SuppressWarnings("NonOverridingEquals")
public abstract boolean equals(int modebits);

/**

+ 1
- 1
tools/BUILD Voir le fichier

@@ -60,7 +60,7 @@ java_package_configuration(
"-Xep:MutableConstantField:ERROR",
"-Xep:NarrowingCompoundAssignment:WARN",
"-Xep:NonAtomicVolatileUpdate:ERROR",
"-Xep:NonOverridingEquals:WARN",
"-Xep:NonOverridingEquals:ERROR",
"-Xep:NullableConstructor:ERROR",
"-Xep:NullablePrimitive:ERROR",
"-Xep:NullableVoid:ERROR",

Chargement…
Annuler
Enregistrer