aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2019-06-16 16:28:02 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2019-06-17 09:40:11 +0900
commit430be8930764260ac7087c37efc9bee52055aa6a (patch)
tree85e5713f6c027e6e4a30ecc82baab39468c76b21
parent13696b8d8c120bf2327b173ad5e8adfa3eb9e6ed (diff)
downloadjgit-430be8930764260ac7087c37efc9bee52055aa6a.tar.gz
jgit-430be8930764260ac7087c37efc9bee52055aa6a.zip
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>
-rw-r--r--org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/AnyLongObjectId.java1
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java1
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java1
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/FileMode.java8
-rw-r--r--tools/BUILD2
5 files changed, 12 insertions, 1 deletions
diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/AnyLongObjectId.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/AnyLongObjectId.java
index 0788922639..e6fe7408a8 100644
--- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/AnyLongObjectId.java
+++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/AnyLongObjectId.java
@@ -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;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java
index 80cf4b3c5f..1b867861b4 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java
@@ -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);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java
index 978dd3a729..791829b429 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java
@@ -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;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/FileMode.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/FileMode.java
index d4c4d5b40d..8fa8d5f7d5 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/FileMode.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/FileMode.java
@@ -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);
/**
diff --git a/tools/BUILD b/tools/BUILD
index 3df7f55c82..9abecc5f72 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -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",