commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject [2/4] commons-compress git commit: silence Sonar where I disagree with it
Date Mon, 19 Dec 2016 17:42:32 GMT
silence Sonar where I disagree with it


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/6b75de47
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/6b75de47
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/6b75de47

Branch: refs/heads/master
Commit: 6b75de47f629a88aa7962fd2b9a2f1f1c1eaf63c
Parents: 8705e97
Author: Stefan Bodewig <bodewig@apache.org>
Authored: Mon Dec 19 18:39:55 2016 +0100
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Mon Dec 19 18:42:11 2016 +0100

----------------------------------------------------------------------
 .../commons/compress/archivers/sevenz/SevenZFile.java    |  2 +-
 .../compress/archivers/sevenz/SevenZOutputFile.java      |  4 ++--
 .../compress/archivers/zip/ZipArchiveInputStream.java    |  3 ++-
 .../apache/commons/compress/archivers/zip/ZipFile.java   |  3 ++-
 .../commons/compress/compressors/bzip2/BlockSort.java    | 11 ++++++-----
 .../compress/compressors/snappy/PureJavaCrc32C.java      |  6 +++---
 6 files changed, 16 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/6b75de47/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
index e0ee6cd..9a14af6 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
@@ -358,7 +358,7 @@ public class SevenZFile implements Closeable {
                 throw new IOException("Multi input/output stream coders are not yet supported");
             }
             inputStreamStack = Coders.addDecoder(fileName, inputStreamStack,
-                    folder.getUnpackSizeForCoder(coder), coder, password);
+                    folder.getUnpackSizeForCoder(coder), coder, password); //NOSONAR
         }
         if (folder.hasCrc) {
             inputStreamStack = new CRC32VerifyingInputStream(inputStreamStack,

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/6b75de47/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java
b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java
index 32bdeb8..dc0140d 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java
@@ -179,10 +179,10 @@ public class SevenZOutputFile implements Closeable {
         }
 
         final SevenZArchiveEntry entry = files.get(files.size() - 1);
-        if (fileBytesWritten > 0) {
+        if (fileBytesWritten > 0) { // this implies currentOutputStream != null
             entry.setHasStream(true);
             ++numNonEmptyStreams;
-            entry.setSize(currentOutputStream.getBytesWritten());
+            entry.setSize(currentOutputStream.getBytesWritten()); //NOSONAR
             entry.setCompressedSize(fileBytesWritten);
             entry.setCrcValue(crc32.getValue());
             entry.setCompressedCrcValue(compressedCrc32.getValue());

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/6b75de47/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
index c127d36..035f804 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
@@ -620,7 +620,8 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
         if (currentEntryHasOutstandingBytes()) {
             drainCurrentEntryData();
         } else {
-            skip(Long.MAX_VALUE);
+            // this is guaranteed to exhaust the stream
+            skip(Long.MAX_VALUE); //NOSONAR
 
             final long inB = current.entry.getMethod() == ZipArchiveOutputStream.DEFLATED
                        ? getBytesInflated() : current.bytesRead;

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/6b75de47/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
index 2b8d15b..d2691fd 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
@@ -483,8 +483,9 @@ public class ZipFile implements Closeable {
         final OffsetEntry offsetEntry = ((Entry) ze).getOffsetEntry();
         ZipUtil.checkRequestedFeatures(ze);
         final long start = offsetEntry.dataOffset;
+        // doesn't get closed if the method is not supported, but doesn't hold any resources
either
         final BoundedInputStream bis =
-            new BoundedInputStream(start, ze.getCompressedSize());
+            new BoundedInputStream(start, ze.getCompressedSize()); //NOSONAR
         switch (ZipMethod.getMethodByCode(ze.getMethod())) {
             case STORED:
                 return bis;

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/6b75de47/src/main/java/org/apache/commons/compress/compressors/bzip2/BlockSort.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/bzip2/BlockSort.java b/src/main/java/org/apache/commons/compress/compressors/bzip2/BlockSort.java
index e2c1232..09c75d5 100644
--- a/src/main/java/org/apache/commons/compress/compressors/bzip2/BlockSort.java
+++ b/src/main/java/org/apache/commons/compress/compressors/bzip2/BlockSort.java
@@ -645,7 +645,7 @@ class BlockSort {
                     HAMMER: while (true) {
                         if (onceRunned) {
                             fmap[j] = a;
-                            if ((j -= h) <= mj) {
+                            if ((j -= h) <= mj) { //NOSONAR
                                 break HAMMER;
                             }
                         } else {
@@ -663,7 +663,7 @@ class BlockSort {
                                 if (block[i1 + 3] == block[i2 + 3]) {
                                     if (block[i1 + 4] == block[i2 + 4]) {
                                         if (block[i1 + 5] == block[i2 + 5]) {
-                                            if (block[(i1 += 6)] == block[(i2 += 6)]) {
+                                            if (block[(i1 += 6)] == block[(i2 += 6)]) { //NOSONAR
                                                 int x = lastShadow;
                                                 X: while (x > 0) {
                                                     x -= 4;
@@ -676,10 +676,10 @@ class BlockSort {
                                                                         if (quadrant[i1 +
2] == quadrant[i2 + 2]) {
                                                                             if (block[i1
+ 4] == block[i2 + 4]) {
                                                                                 if (quadrant[i1
+ 3] == quadrant[i2 + 3]) {
-                                                                                    if ((i1
+= 4) >= lastPlus1) {
+                                                                                    if ((i1
+= 4) >= lastPlus1) { //NOSONAR
                                                                                         i1
-= lastPlus1;
                                                                                     }
-                                                                                    if ((i2
+= 4) >= lastPlus1) {
+                                                                                    if ((i2
+= 4) >= lastPlus1) { //NOSONAR
                                                                                         i2
-= lastPlus1;
                                                                                     }
                                                                                     workDoneShadow++;
@@ -973,7 +973,8 @@ class BlockSort {
             runningOrder[i] = i;
         }
 
-        for (int h = 364; h != 1;) {
+        // h = 364, 121, 40, 13, 4, 1
+        for (int h = 364; h != 1;) { //NOSONAR
             h /= 3;
             for (int i = h; i <= 255; i++) {
                 final int vv = runningOrder[i];

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/6b75de47/src/main/java/org/apache/commons/compress/compressors/snappy/PureJavaCrc32C.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/snappy/PureJavaCrc32C.java
b/src/main/java/org/apache/commons/compress/compressors/snappy/PureJavaCrc32C.java
index cb735d5..6f216ff 100644
--- a/src/main/java/org/apache/commons/compress/compressors/snappy/PureJavaCrc32C.java
+++ b/src/main/java/org/apache/commons/compress/compressors/snappy/PureJavaCrc32C.java
@@ -60,9 +60,9 @@ final class PureJavaCrc32C implements Checksum {
 
     while(len > 7) {
       final int c0 =(b[off+0] ^ localCrc) & 0xff;
-      final int c1 =(b[off+1] ^ (localCrc >>>= 8)) & 0xff;
-      final int c2 =(b[off+2] ^ (localCrc >>>= 8)) & 0xff;
-      final int c3 =(b[off+3] ^ (localCrc >>>= 8)) & 0xff;
+      final int c1 =(b[off+1] ^ (localCrc >>>= 8)) & 0xff; //NOSONAR
+      final int c2 =(b[off+2] ^ (localCrc >>>= 8)) & 0xff; //NOSONAR
+      final int c3 =(b[off+3] ^ (localCrc >>>= 8)) & 0xff; //NOSONAR
       localCrc = (T[T8_7_start + c0] ^ T[T8_6_start + c1])
           ^ (T[T8_5_start + c2] ^ T[T8_4_start + c3]);
 


Mime
View raw message