Increase severity of OperatorPrecedence to ERROR, and fix instances

Fix all remaining instances of the OperatorPrededence warning, by adding
parentheses to make the precedence explicit.

Change-Id: Ib296dfed09f9be042d0ff0f7fad8214e4dd766b4
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
David Pursehouse 2019-06-12 09:06:46 +09:00
parent c177c6f4c5
commit 0f4554f126
8 changed files with 13 additions and 12 deletions

View File

@ -64,7 +64,7 @@ public final class WildMatcher extends AbstractMatcher {
public final boolean matches(String path, boolean assumeDirectory,
boolean pathMatch) {
return !dirOnly || assumeDirectory
|| !pathMatch && isSubdirectory(path);
|| (!pathMatch && isSubdirectory(path));
}
/** {@inheritDoc} */

View File

@ -429,7 +429,7 @@ protected boolean onAppendBase(final int typeCode, final byte[] data,
final byte[] buf = buffer();
int sz = data.length;
int len = 0;
buf[len++] = (byte) ((typeCode << 4) | sz & 15);
buf[len++] = (byte) ((typeCode << 4) | (sz & 15));
sz >>>= 4;
while (sz > 0) {
buf[len - 1] |= 0x80;

View File

@ -353,7 +353,7 @@ protected boolean onAppendBase(final int typeCode, final byte[] data,
final byte[] buf = buffer();
int sz = data.length;
int len = 0;
buf[len++] = (byte) ((typeCode << 4) | sz & 15);
buf[len++] = (byte) ((typeCode << 4) | (sz & 15));
sz >>>= 4;
while (sz > 0) {
buf[len - 1] |= 0x80;

View File

@ -295,7 +295,7 @@ static boolean isStandardFormat(byte[] hdr) {
* can always correctly determine the buffer format.
*/
final int fb = hdr[0] & 0xff;
return (fb & 0x8f) == 0x08 && (((fb << 8) | hdr[1] & 0xff) % 31) == 0;
return (fb & 0x8f) == 0x08 && (((fb << 8) | (hdr[1] & 0xff)) % 31) == 0;
}
static InputStream inflate(final InputStream in, final long size,

View File

@ -677,7 +677,7 @@ private void negotiate(ProgressMonitor monitor) throws IOException,
state.writeTo(out, null);
}
if (receivedContinue && havesSinceLastContinue > MAX_HAVES
if ((receivedContinue && havesSinceLastContinue > MAX_HAVES)
|| havesSent >= maxHaves) {
// Our history must be really different from the remote's.
// We just sent a whole slew of have lines, and it did not

View File

@ -397,8 +397,9 @@ private String findMatch(Set<String> names, URIish uri) {
// A longer path match is always preferred even over a user
// match. If the path matches are equal, a match with user wins
// over a match without user.
if (matchLength > bestMatchLength || !withUser && hasUser
&& matchLength >= 0 && matchLength == bestMatchLength) {
if (matchLength > bestMatchLength
|| (!withUser && hasUser && matchLength >= 0
&& matchLength == bestMatchLength)) {
bestMatch = s;
bestMatchLength = matchLength;
withUser = hasUser;
@ -444,7 +445,7 @@ static int segmentCompare(String uriPath, String m) {
int uLength = uriPath.length();
int mLength = matchPath.length();
if (mLength == uLength || matchPath.charAt(mLength - 1) == '/'
|| mLength < uLength && uriPath.charAt(mLength) == '/') {
|| (mLength < uLength && uriPath.charAt(mLength) == '/')) {
return mLength;
}
return -1;
@ -464,7 +465,7 @@ static String normalize(String path) {
if (slash < 0) {
slash = length;
}
if (slash == i || slash == i + 1 && path.charAt(i) == '.') {
if (slash == i || (slash == i + 1 && path.charAt(i) == '.')) {
// Skip /. or also double slashes
} else if (slash == i + 2 && path.charAt(i) == '.'
&& path.charAt(i + 1) == '.') {

View File

@ -362,8 +362,8 @@ private String cleanLeadingSlashes(String p, String s) {
if (p.length() >= 3
&& p.charAt(0) == '/'
&& p.charAt(2) == ':'
&& (p.charAt(1) >= 'A' && p.charAt(1) <= 'Z' || p.charAt(1) >= 'a'
&& p.charAt(1) <= 'z'))
&& ((p.charAt(1) >= 'A' && p.charAt(1) <= 'Z')
|| (p.charAt(1) >= 'a' && p.charAt(1) <= 'z')))
return p.substring(1);
else if (s != null && p.length() >= 2 && p.charAt(0) == '/'
&& p.charAt(1) == '~')

View File

@ -64,7 +64,7 @@ java_package_configuration(
"-Xep:NullableConstructor:ERROR",
"-Xep:NullablePrimitive:ERROR",
"-Xep:NullableVoid:ERROR",
"-Xep:OperatorPrecedence:WARN",
"-Xep:OperatorPrecedence:ERROR",
"-Xep:OverridesGuiceInjectableMethod:ERROR",
"-Xep:PreconditionsInvalidPlaceholder:ERROR",
"-Xep:ProtoFieldPreconditionsCheckNotNull:ERROR",