commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1150096 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress: archivers/ archivers/ar/ archivers/cpio/ archivers/jar/ archivers/tar/ archivers/zip/ changes/ compressors/bzip2/
Date Sat, 23 Jul 2011 12:41:57 GMT
Author: bodewig
Date: Sat Jul 23 12:41:55 2011
New Revision: 1150096

URL: http://svn.apache.org/viewvc?rev=1150096&view=rev
Log:
reduce PMD whining

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/Lister.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveEntry.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSetPerformer.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java?rev=1150096&r1=1150095&r2=1150096&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
Sat Jul 23 12:41:55 2011
@@ -222,7 +222,9 @@ public class ArchiveStreamFactory {
                 TarArchiveInputStream tais = new TarArchiveInputStream(new ByteArrayInputStream(tarheader));
                 tais.getNextEntry();
                 return new TarArchiveInputStream(in);
-            } catch (Exception e) { // can generate IllegalArgumentException as well as IOException
+            } catch (Exception e) { // NOPMD
+                // can generate IllegalArgumentException as well as IOException
+                // autodetection, simply not a TAR
                 // ignored
             }
         } catch (IOException e) {

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/Lister.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/Lister.java?rev=1150096&r1=1150095&r2=1150096&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/Lister.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/Lister.java
Sat Jul 23 12:41:55 2011
@@ -23,10 +23,6 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
 
-import org.apache.commons.compress.archivers.ArchiveEntry;
-import org.apache.commons.compress.archivers.ArchiveInputStream;
-import org.apache.commons.compress.archivers.ArchiveStreamFactory;
-
 /**
  * Simple command line application that lists the contents of an archive.
  *

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java?rev=1150096&r1=1150095&r2=1150096&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
Sat Jul 23 12:41:55 2011
@@ -98,11 +98,9 @@ public class ArArchiveInputStream extend
             }
         }
 
-        if (offset % 2 != 0) {
-            if (read() < 0) {
-                // hit eof
-                return null;
-            }
+        if (offset % 2 != 0 && read() < 0) {
+            // hit eof
+            return null;
         }
 
         if (input.available() == 0) {

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java?rev=1150096&r1=1150095&r2=1150096&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
Sat Jul 23 12:41:55 2011
@@ -130,7 +130,7 @@ public class CpioArchiveInputStream exte
      */
     private void closeEntry() throws IOException {
         ensureOpen();
-        while (read(this.tmpbuf, 0, this.tmpbuf.length) != -1) {
+        while (read(this.tmpbuf, 0, this.tmpbuf.length) != -1) { // NOPMD
             // do nothing
         }
 
@@ -237,10 +237,10 @@ public class CpioArchiveInputStream exte
         if (this.entryBytesRead == this.entry.getSize()) {
             skip(entry.getDataPadCount());
             this.entryEOF = true;
-            if (this.entry.getFormat() == FORMAT_NEW_CRC) {
-                if (this.crc != this.entry.getChksum()) {
-                    throw new IOException("CRC Error. Occured at byte: " + getBytesRead());
-                }
+            if (this.entry.getFormat() == FORMAT_NEW_CRC
+                && this.crc != this.entry.getChksum()) {
+                throw new IOException("CRC Error. Occured at byte: "
+                                      + getBytesRead());
             }
             return -1; // EOF for this entry
         }

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java?rev=1150096&r1=1150095&r2=1150096&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java
Sat Jul 23 12:41:55 2011
@@ -334,10 +334,9 @@ public class CpioArchiveOutputStream ext
                     + " bytes)");
         }
         pad(this.entry.getDataPadCount());
-        if (this.entry.getFormat() == FORMAT_NEW_CRC) {
-            if (this.crc != this.entry.getChksum()) {
-                throw new IOException("CRC Error");
-            }
+        if (this.entry.getFormat() == FORMAT_NEW_CRC
+            && this.crc != this.entry.getChksum()) {
+            throw new IOException("CRC Error");
         }
         this.entry = null;
         this.crc = 0;

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveEntry.java?rev=1150096&r1=1150095&r2=1150096&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveEntry.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveEntry.java
Sat Jul 23 12:41:55 2011
@@ -66,17 +66,4 @@ public class JarArchiveEntry extends Zip
             return null;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.commons.compress.archivers.zip.ZipArchiveEntry#equals(java.lang.Object)
-     */
-    public boolean equals(Object obj) {
-        return super.equals(obj);
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.commons.compress.archivers.zip.ZipArchiveEntry#hashCode()
-     */
-    public int hashCode() {
-        return super.hashCode();
-    }
 }

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java?rev=1150096&r1=1150095&r2=1150096&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java
Sat Jul 23 12:41:55 2011
@@ -173,10 +173,8 @@ class TarBuffer { // Not public, because
             throw new IOException("reading (via skip) from an output buffer");
         }
 
-        if (currRecIdx >= recsPerBlock) {
-            if (!readBlock()) {
-                return;    // UNDONE
-            }
+        if (currRecIdx >= recsPerBlock && !readBlock()) {
+            return;    // UNDONE
         }
 
         currRecIdx++;
@@ -196,10 +194,8 @@ class TarBuffer { // Not public, because
             throw new IOException("reading from an output buffer");
         }
 
-        if (currRecIdx >= recsPerBlock) {
-            if (!readBlock()) {
-                return null;
-            }
+        if (currRecIdx >= recsPerBlock && !readBlock()) {
+            return null;
         }
 
         byte[] result = new byte[recordSize];
@@ -407,9 +403,8 @@ class TarBuffer { // Not public, because
         } else if (inStream != null) {
             if (inStream != System.in) {
                 inStream.close();
-
-                inStream = null;
             }
+            inStream = null;
         }
     }
 }

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java?rev=1150096&r1=1150095&r2=1150096&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
Sat Jul 23 12:41:55 2011
@@ -528,23 +528,21 @@ public class ZipArchiveOutputStream exte
     public void write(byte[] b, int offset, int length) throws IOException {
         ZipUtil.checkRequestedFeatures(entry);
         if (entry.getMethod() == DEFLATED) {
-            if (length > 0) {
-                if (!def.finished()) {
-                    if (length <= DEFLATER_BLOCK_SIZE) {
-                        def.setInput(b, offset, length);
+            if (length > 0 && !def.finished()) {
+                if (length <= DEFLATER_BLOCK_SIZE) {
+                    def.setInput(b, offset, length);
+                    deflateUntilInputIsNeeded();
+                } else {
+                    final int fullblocks = length / DEFLATER_BLOCK_SIZE;
+                    for (int i = 0; i < fullblocks; i++) {
+                        def.setInput(b, offset + i * DEFLATER_BLOCK_SIZE,
+                                     DEFLATER_BLOCK_SIZE);
+                        deflateUntilInputIsNeeded();
+                    }
+                    final int done = fullblocks * DEFLATER_BLOCK_SIZE;
+                    if (done < length) {
+                        def.setInput(b, offset + done, length - done);
                         deflateUntilInputIsNeeded();
-                    } else {
-                        final int fullblocks = length / DEFLATER_BLOCK_SIZE;
-                        for (int i = 0; i < fullblocks; i++) {
-                            def.setInput(b, offset + i * DEFLATER_BLOCK_SIZE,
-                                         DEFLATER_BLOCK_SIZE);
-                            deflateUntilInputIsNeeded();
-                        }
-                        final int done = fullblocks * DEFLATER_BLOCK_SIZE;
-                        if (done < length) {
-                            def.setInput(b, offset + done, length - done);
-                            deflateUntilInputIsNeeded();
-                        }
                     }
                 }
             }

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java?rev=1150096&r1=1150095&r2=1150096&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
Sat Jul 23 12:41:55 2011
@@ -200,7 +200,7 @@ public class ZipFile {
                 try {
                     closed = true;
                     archive.close();
-                } catch (IOException e2) {
+                } catch (IOException e2) { // NOPMD
                     // swallow, throw the original exception instead
                 }
             }
@@ -238,8 +238,8 @@ public class ZipFile {
         if (zipfile != null) {
             try {
                 zipfile.close();
-            } catch (IOException e) {
-                //ignore
+            } catch (IOException e) { // NOPMD
+                //ignore, that's why the method is called "quietly"
             }
         }
     }

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSetPerformer.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSetPerformer.java?rev=1150096&r1=1150095&r2=1150096&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSetPerformer.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSetPerformer.java
Sat Jul 23 12:41:55 2011
@@ -96,8 +96,9 @@ public class ChangeSetPerformer {
                         results.deleted(name);
                         break;
                     }
-                } else if(type == Change.TYPE_DELETE_DIR && name != null) {
-                    if (name.startsWith(change.targetFile() + "/")) {
+                } else if (type == Change.TYPE_DELETE_DIR && name != null) {
+                    // don't combine ifs to make future extensions more easy
+                    if (name.startsWith(change.targetFile() + "/")) { // NOPMD
                         copy = false;
                         results.deleted(name);
                         break;
@@ -105,11 +106,11 @@ public class ChangeSetPerformer {
                 }
             }
 
-            if (copy) {
-                if (!isDeletedLater(workingSet, entry) && !results.hasBeenAdded(entry.getName()))
{
-                    copyStream(in, out, entry);
-                    results.addedFromStream(entry.getName());
-                }
+            if (copy
+                && !isDeletedLater(workingSet, entry)
+                && !results.hasBeenAdded(entry.getName())) {
+                copyStream(in, out, entry);
+                results.addedFromStream(entry.getName());
             }
         }
         

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java?rev=1150096&r1=1150095&r2=1150096&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java
Sat Jul 23 12:41:55 2011
@@ -942,7 +942,7 @@ public class BZip2CompressorInputStream 
          * I don't initialize it at construction time to avoid unneccessary
          * memory allocation when compressing small files.
          */
-        final int[] initTT(int length) {
+        int[] initTT(int length) {
             int[] ttShadow = this.tt;
 
             // tt.length should always be >= length, but theoretically

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java?rev=1150096&r1=1150095&r2=1150096&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
Sat Jul 23 12:41:55 2011
@@ -772,7 +772,7 @@ public class BZip2CompressorOutputStream
         sendMTFValues6(nGroups, alphaSize);
 
         /* And finally, the block data proper */
-        sendMTFValues7(nSelectors);
+        sendMTFValues7();
     }
 
     private void sendMTFValues0(final int nGroups, final int alphaSize) {
@@ -1125,7 +1125,7 @@ public class BZip2CompressorOutputStream
         this.bsLive = bsLiveShadow;
     }
 
-    private void sendMTFValues7(final int nSelectors) throws IOException {
+    private void sendMTFValues7() throws IOException {
         final Data dataShadow = this.data;
         final byte[][] len = dataShadow.sendMTFValues_len;
         final int[][] code = dataShadow.sendMTFValues_code;



Mime
View raw message