commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject [2/3] commons-compress git commit: PMD findings
Date Thu, 11 May 2017 18:49:10 GMT
PMD findings


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

Branch: refs/heads/master
Commit: 591b9f9795c6eaf782580327e82a70164a640d34
Parents: e646770
Author: Stefan Bodewig <bodewig@apache.org>
Authored: Thu May 11 20:43:09 2017 +0200
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Thu May 11 20:43:09 2017 +0200

----------------------------------------------------------------------
 .../apache/commons/compress/archivers/sevenz/SevenZFile.java   | 6 +++---
 .../compress/archivers/zip/ResourceAlignmentExtraField.java    | 3 ++-
 .../commons/compress/archivers/zip/ZipArchiveOutputStream.java | 2 +-
 .../compressors/brotli/BrotliCompressorInputStream.java        | 1 -
 .../compressors/lz4/BlockLZ4CompressorOutputStream.java        | 1 -
 .../commons/compress/compressors/lz77support/Parameters.java   | 2 +-
 6 files changed, 7 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/591b9f97/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 9ad0746..e0de903 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
@@ -803,7 +803,7 @@ public class SevenZFile implements Closeable {
         int nonEmptyFileCounter = 0;
         int emptyFileCounter = 0;
         for (int i = 0; i < files.length; i++) {
-            files[i].setHasStream(isEmptyStream == null ? true : !isEmptyStream.get(i));
+            files[i].setHasStream(isEmptyStream == null || !isEmptyStream.get(i));
             if (files[i].hasStream()) {
                 files[i].setDirectory(false);
                 files[i].setAntiItem(false);
@@ -812,8 +812,8 @@ public class SevenZFile implements Closeable {
                 files[i].setSize(archive.subStreamsInfo.unpackSizes[nonEmptyFileCounter]);
                 ++nonEmptyFileCounter;
             } else {
-                files[i].setDirectory(isEmptyFile == null ? true : !isEmptyFile.get(emptyFileCounter));
-                files[i].setAntiItem(isAnti == null ? false : isAnti.get(emptyFileCounter));
+                files[i].setDirectory(isEmptyFile == null || !isEmptyFile.get(emptyFileCounter));
+                files[i].setAntiItem(isAnti != null && isAnti.get(emptyFileCounter));
                 files[i].setHasCrc(false);
                 files[i].setSize(0);
                 ++emptyFileCounter;

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/591b9f97/src/main/java/org/apache/commons/compress/archivers/zip/ResourceAlignmentExtraField.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ResourceAlignmentExtraField.java
b/src/main/java/org/apache/commons/compress/archivers/zip/ResourceAlignmentExtraField.java
index 79e20f6..3d0741c 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ResourceAlignmentExtraField.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ResourceAlignmentExtraField.java
@@ -64,8 +64,9 @@ public class ResourceAlignmentExtraField implements ZipExtraField {
     }
 
     public ResourceAlignmentExtraField(int alignment, boolean allowMethodChange, int padding)
{
-        if (alignment < 0 || alignment > 0x7fff)
+        if (alignment < 0 || alignment > 0x7fff) {
             throw new IllegalArgumentException("Alignment must be between 0 and 0x7fff, was:
" + alignment);
+        }
         this.alignment = (short) alignment;
         this.allowMethodChange = allowMethodChange;
         this.padding = padding;

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/591b9f97/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
index c667356..2b3af25 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
@@ -1057,7 +1057,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
                             - ResourceAlignmentExtraField.BASE_SIZE) &
                             (alignment - 1));
             ze.addExtraField(new ResourceAlignmentExtraField(alignment,
-                            oldAlignmentEx != null ? oldAlignmentEx.allowMethodChange() :
false, padding));
+                            oldAlignmentEx != null && oldAlignmentEx.allowMethodChange(),
padding));
         }
 
         final byte[] extra = ze.getLocalFileDataExtra();

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/591b9f97/src/main/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStream.java
b/src/main/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStream.java
index 135988d..91e57ca 100644
--- a/src/main/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStream.java
@@ -17,7 +17,6 @@
 
 package org.apache.commons.compress.compressors.brotli;
 
-import java.io.FilterInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/591b9f97/src/main/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorOutputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorOutputStream.java
b/src/main/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorOutputStream.java
index 9330ea8..9326023 100644
--- a/src/main/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/lz4/BlockLZ4CompressorOutputStream.java
@@ -40,7 +40,6 @@ import org.apache.commons.compress.utils.ByteUtils;
 public class BlockLZ4CompressorOutputStream extends CompressorOutputStream {
 
     private static final int MIN_BACK_REFERENCE_LENGTH = 4;
-    private static final int MIN_LENGTH_OF_LAST_LITERAL = 5;
     private static final int MIN_OFFSET_OF_LAST_BACK_REFERENCE = 12;
 
     /*

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/591b9f97/src/main/java/org/apache/commons/compress/compressors/lz77support/Parameters.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/lz77support/Parameters.java
b/src/main/java/org/apache/commons/compress/compressors/lz77support/Parameters.java
index d61ff65..fe892f3 100644
--- a/src/main/java/org/apache/commons/compress/compressors/lz77support/Parameters.java
+++ b/src/main/java/org/apache/commons/compress/compressors/lz77support/Parameters.java
@@ -248,7 +248,7 @@ public final class Parameters {
             int niceLen = niceBackReferenceLength != null ? niceBackReferenceLength
                 : Math.max(minBackReferenceLength, maxBackReferenceLength / 2);
             int candidates = maxCandidates != null ? maxCandidates : Math.max(256, windowSize
/ 128);
-            boolean lazy = lazyMatches != null ? lazyMatches : true;
+            boolean lazy = lazyMatches == null || lazyMatches;
             int threshold = lazy ? (lazyThreshold != null ? lazyThreshold : niceLen) : minBackReferenceLength;
 
             return new Parameters(windowSize, minBackReferenceLength, maxBackReferenceLength,


Mime
View raw message