aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2019-06-22 18:47:43 +0900
committerMatthias Sohn <matthias.sohn@sap.com>2019-08-08 14:28:27 +0200
commit72ae0892066fb4875136cf77c624194e394c0856 (patch)
tree5326dcf601d141d45553132248e8b224e73812ef
parentaefb11298c36960c4ae49fa830c8a93f1171f52f (diff)
downloadjgit-72ae0892066fb4875136cf77c624194e394c0856.tar.gz
jgit-72ae0892066fb4875136cf77c624194e394c0856.zip
Fix NarrowingCompoundAssignment warnings from Error Prone
Error Prone reports: [NarrowingCompoundAssignment] Compound assignments from long to int hide lossy casts and [NarrowingCompoundAssignment] Compound assignments from int to byte hide lossy casts See https://errorprone.info/bugpattern/NarrowingCompoundAssignment Fix the warnings by adding explicit casts or changing types as necessary. Now that all occurrences of the warning are fixed, increase its severity to ERROR. Change-Id: Idb3670e6047b146ae37daee07212ff9455512623 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackParser.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryPackParser.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/BinaryDelta.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/revwalk/FooterLine.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/TreeFilterMarker.java2
-rw-r--r--tools/BUILD2
10 files changed, 18 insertions, 17 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java
index 2ae9c11a7d..62495fb023 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java
@@ -842,9 +842,9 @@ public class MergerTest extends RepositoryTestCase {
* Throws an exception if reading beyond limit.
*/
static class BigReadForbiddenStream extends ObjectStream.Filter {
- int limit;
+ long limit;
- BigReadForbiddenStream(ObjectStream orig, int limit) {
+ BigReadForbiddenStream(ObjectStream orig, long limit) {
super(orig.getType(), orig.getSize(), orig);
this.limit = limit;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java
index d2a59c1310..d4db15ce9b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java
@@ -448,9 +448,9 @@ public class DirCacheEntry {
*/
public void setAssumeValid(boolean assume) {
if (assume)
- info[infoOffset + P_FLAGS] |= ASSUME_VALID;
+ info[infoOffset + P_FLAGS] |= (byte) ASSUME_VALID;
else
- info[infoOffset + P_FLAGS] &= ~ASSUME_VALID;
+ info[infoOffset + P_FLAGS] &= (byte) ~ASSUME_VALID;
}
/**
@@ -470,9 +470,9 @@ public class DirCacheEntry {
*/
public void setUpdateNeeded(boolean updateNeeded) {
if (updateNeeded)
- inCoreFlags |= UPDATE_NEEDED;
+ inCoreFlags |= (byte) UPDATE_NEEDED;
else
- inCoreFlags &= ~UPDATE_NEEDED;
+ inCoreFlags &= (byte) ~UPDATE_NEEDED;
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java
index ca11fb9265..f10a1d8127 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java
@@ -661,7 +661,7 @@ public class DfsGarbageCollector {
private int objectsBefore() {
int cnt = 0;
for (DfsPackFile p : packsBefore)
- cnt += p.getPackDescription().getObjectCount();
+ cnt += (int) p.getPackDescription().getObjectCount();
return cnt;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackParser.java
index 45e3b199f7..e4c37cb4c2 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackParser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackParser.java
@@ -432,7 +432,7 @@ public class DfsPackParser extends PackParser {
buf[len++] = (byte) ((typeCode << 4) | (sz & 15));
sz >>>= 4;
while (sz > 0) {
- buf[len - 1] |= 0x80;
+ buf[len - 1] |= (byte) 0x80;
buf[len++] = (byte) (sz & 0x7f);
sz >>>= 7;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryPackParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryPackParser.java
index ade7a8e96d..7d31673566 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryPackParser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryPackParser.java
@@ -356,7 +356,7 @@ public class ObjectDirectoryPackParser extends PackParser {
buf[len++] = (byte) ((typeCode << 4) | (sz & 15));
sz >>>= 4;
while (sz > 0) {
- buf[len - 1] |= 0x80;
+ buf[len - 1] |= (byte) 0x80;
buf[len++] = (byte) (sz & 0x7f);
sz >>>= 7;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/BinaryDelta.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/BinaryDelta.java
index c7e5ad6232..5f69d0a884 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/BinaryDelta.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/BinaryDelta.java
@@ -142,7 +142,7 @@ public class BinaryDelta {
int c, shift = 0;
do {
c = delta[deltaPtr++] & 0xff;
- baseLen |= ((long) (c & 0x7f)) << shift;
+ baseLen |= (c & 0x7f) << shift;
shift += 7;
} while ((c & 0x80) != 0);
if (base.length != baseLen)
@@ -155,7 +155,7 @@ public class BinaryDelta {
shift = 0;
do {
c = delta[deltaPtr++] & 0xff;
- resLen |= ((long) (c & 0x7f)) << shift;
+ resLen |= (c & 0x7f) << shift;
shift += 7;
} while ((c & 0x80) != 0);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java
index 42d1330af9..ce1eb597fc 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java
@@ -642,11 +642,12 @@ public class IndexDiff {
private void addConflict(String path, int stage) {
StageState existingStageStates = conflicts.get(path);
byte stageMask = 0;
- if (existingStageStates != null)
- stageMask |= existingStageStates.getStageMask();
+ if (existingStageStates != null) {
+ stageMask |= (byte) existingStageStates.getStageMask();
+ }
// stage 1 (base) should be shifted 0 times
int shifts = stage - 1;
- stageMask |= (1 << shifts);
+ stageMask |= (byte) (1 << shifts);
StageState stageState = StageState.fromMask(stageMask);
conflicts.put(path, stageState);
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/FooterLine.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/FooterLine.java
index d6fed66702..84b6d2e481 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/FooterLine.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/FooterLine.java
@@ -95,7 +95,7 @@ public final class FooterLine {
for (int kPtr = 0; kPtr < len;) {
byte b = buffer[bPtr++];
if ('A' <= b && b <= 'Z')
- b += 'a' - 'A';
+ b += (byte) ('a' - 'A');
if (b != kRaw[kPtr++])
return false;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/TreeFilterMarker.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/TreeFilterMarker.java
index 738ccbd8b7..c28f03534c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/TreeFilterMarker.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/TreeFilterMarker.java
@@ -113,7 +113,7 @@ public class TreeFilterMarker {
try {
boolean marked = filter.include(walk);
if (marked)
- marks |= (1L << index);
+ marks |= (1 << index);
} catch (StopWalkException e) {
// Don't check tree filter anymore, it will no longer
// match
diff --git a/tools/BUILD b/tools/BUILD
index 20c82c5700..ea2b91b022 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -58,7 +58,7 @@ java_package_configuration(
"-Xep:MissingFail:ERROR",
"-Xep:MissingOverride:ERROR",
"-Xep:MutableConstantField:ERROR",
- "-Xep:NarrowingCompoundAssignment:WARN",
+ "-Xep:NarrowingCompoundAssignment:ERROR",
"-Xep:NonAtomicVolatileUpdate:ERROR",
"-Xep:NonOverridingEquals:ERROR",
"-Xep:NullableConstructor:ERROR",