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>
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 0788922..e6fe740 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 final int hashCode() {
 	 *            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 80cf4b3..1b86786 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 void waitUntilNotRacy() throws InterruptedException {
 	 *            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 978dd3a..791829b 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 final int hashCode() {
 	 *            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 d4c4d5b..8fa8d5f 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 boolean equals(int modeBits) {
 	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 boolean equals(int modeBits) {
 	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 boolean equals(int modeBits) {
 	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 boolean equals(int modeBits) {
 	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 boolean equals(int modeBits) {
 	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 static final FileMode fromBits(int bits) {
 
 		return new FileMode(bits, Constants.OBJ_BAD) {
 			@Override
+			@SuppressWarnings("NonOverridingEquals")
 			public boolean equals(int a) {
 				return bits == a;
 			}
@@ -206,6 +213,7 @@ private FileMode(int mode, int expType) {
 	 *            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 3df7f55..9abecc5 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -60,7 +60,7 @@
         "-Xep:MutableConstantField:ERROR",
         "-Xep:NarrowingCompoundAssignment:WARN",
         "-Xep:NonAtomicVolatileUpdate:ERROR",
-        "-Xep:NonOverridingEquals:WARN",
+        "-Xep:NonOverridingEquals:ERROR",
         "-Xep:NullableConstructor:ERROR",
         "-Xep:NullablePrimitive:ERROR",
         "-Xep:NullableVoid:ERROR",