commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1307765 - in /commons/proper/compress/trunk: ./ src/main/java/org/apache/commons/compress/archivers/cpio/ src/main/java/org/apache/commons/compress/archivers/tar/ src/main/java/org/apache/commons/compress/archivers/zip/ src/main/java/org/a...
Date Sat, 31 Mar 2012 10:59:47 GMT
Author: sebb
Date: Sat Mar 31 10:59:47 2012
New Revision: 1307765

URL: http://svn.apache.org/viewvc?rev=1307765&view=rev
Log:
Always use blocks for conditional statements

Modified:
    commons/proper/compress/trunk/pmd-ruleset.xml
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.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/compressors/bzip2/BZip2CompressorInputStream.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZCompressorInputStream.java

Modified: commons/proper/compress/trunk/pmd-ruleset.xml
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/pmd-ruleset.xml?rev=1307765&r1=1307764&r2=1307765&view=diff
==============================================================================
--- commons/proper/compress/trunk/pmd-ruleset.xml (original)
+++ commons/proper/compress/trunk/pmd-ruleset.xml Sat Mar 31 10:59:47 2012
@@ -30,4 +30,5 @@
   <rule ref="rulesets/finalizers.xml"/>
   <rule ref="rulesets/imports.xml"/>
   <rule ref="rulesets/unusedcode.xml"/>
+  <rule ref="rulesets/braces.xml"/>
 </ruleset>

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java?rev=1307765&r1=1307764&r2=1307765&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java
Sat Mar 31 10:59:47 2012
@@ -467,7 +467,7 @@ public class CpioArchiveEntry implements
      * @return the number of bytes needed to pad the header (0,1,2,3)
      */
     public int getHeaderPadCount(){
-        if (this.alignmentBoundary == 0) return 0;
+        if (this.alignmentBoundary == 0) { return 0; }
         int size = this.headerSize+this.name.length()+1; // Name has terminating null
         int remain = size % this.alignmentBoundary;
         if (remain > 0){
@@ -482,7 +482,7 @@ public class CpioArchiveEntry implements
      * @return the number of bytes needed to pad the data (0,1,2,3)
      */
     public int getDataPadCount(){
-        if (this.alignmentBoundary == 0) return 0;
+        if (this.alignmentBoundary == 0) { return 0; }
         long size = this.filesize;
         int remain = (int) (size % this.alignmentBoundary);
         if (remain > 0){

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java?rev=1307765&r1=1307764&r2=1307765&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
Sat Mar 31 10:59:47 2012
@@ -1044,10 +1044,12 @@ public class TarArchiveEntry implements 
      */
     private int evaluateType(byte[] header) {
         final ByteBuffer magic = ByteBuffer.wrap(header, MAGIC_OFFSET, MAGICLEN);
-        if (magic.compareTo(ByteBuffer.wrap(MAGIC_GNU.getBytes())) == 0)
+        if (magic.compareTo(ByteBuffer.wrap(MAGIC_GNU.getBytes())) == 0) {
             return FORMAT_OLDGNU;
-        if (magic.compareTo(ByteBuffer.wrap(MAGIC_POSIX.getBytes())) == 0)
+        }
+        if (magic.compareTo(ByteBuffer.wrap(MAGIC_POSIX.getBytes())) == 0) {
             return FORMAT_POSIX;
+        }
         return 0;
     }
 }

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=1307765&r1=1307764&r2=1307765&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 Mar 31 10:59:47 2012
@@ -952,8 +952,9 @@ public class ZipFile {
     private final Comparator<ZipArchiveEntry> OFFSET_COMPARATOR =
         new Comparator<ZipArchiveEntry>() {
         public int compare(ZipArchiveEntry e1, ZipArchiveEntry e2) {
-            if (e1 == e2)
+            if (e1 == e2) {
                 return 0;
+            }
 
             OffsetEntry off1 = entries.get(e1);
             OffsetEntry off2 = entries.get(e2);

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=1307765&r1=1307764&r2=1307765&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 Mar 31 10:59:47 2012
@@ -192,8 +192,9 @@ public class BZip2CompressorInputStream 
         int nInUseShadow = 0;
 
         for (int i = 0; i < 256; i++) {
-            if (inUse[i])
+            if (inUse[i]) {
                 seqToUnseq[nInUseShadow++] = (byte) i;
+            }
         }
 
         this.nInUse = nInUseShadow;
@@ -246,13 +247,15 @@ public class BZip2CompressorInputStream 
         int magic0 = this.in.read();
         int magic1 = this.in.read();
         int magic2 = this.in.read();
-        if (magic0 == -1 && !isFirstStream)
+        if (magic0 == -1 && !isFirstStream) {
             return false;
+        }
 
-        if (magic0 != 'B' || magic1 != 'Z' || magic2 != 'h')
+        if (magic0 != 'B' || magic1 != 'Z' || magic2 != 'h') {
             throw new IOException(isFirstStream
                     ? "Stream is not in the BZip2 format"
                     : "Garbage after a valid BZip2 stream");
+        }
 
         int blockSize = this.in.read();
         if ((blockSize < '1') || (blockSize > '9')) {
@@ -286,14 +289,16 @@ public class BZip2CompressorInputStream 
 
             // If isn't end of stream magic, break out of the loop.
             if (magic0 != 0x17 || magic1 != 0x72 || magic2 != 0x45
-                    || magic3 != 0x38 || magic4 != 0x50 || magic5 != 0x90)
+                    || magic3 != 0x38 || magic4 != 0x50 || magic5 != 0x90) {
                 break;
+            }
 
             // End of stream was reached. Check the combined CRC and
             // advance to the next .bz2 stream if decoding concatenated
             // streams.
-            if (complete())
+            if (complete()) {
                 return;
+            }
         }
 
         if (magic0 != 0x31 || // '1'

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=1307765&r1=1307764&r2=1307765&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 Mar 31 10:59:47 2012
@@ -1564,8 +1564,9 @@ public class BZip2CompressorOutputStream
             c1 = c2;
         }
 
-        for (int i = 1; i <= 65536; i++)
+        for (int i = 1; i <= 65536; i++) {
             ftab[i] += ftab[i - 1];
+        }
 
         c1 = block[1] & 0xff;
         for (int i = 0; i < lastShadow; i++) {
@@ -1654,8 +1655,9 @@ public class BZip2CompressorOutputStream
                 }
             }
 
-            for (int j = 256; --j >= 0;)
+            for (int j = 256; --j >= 0;) {
                 ftab[(j << 8) + ss] |= SETMASK;
+            }
 
             // Step 3:
             /*
@@ -1694,8 +1696,9 @@ public class BZip2CompressorOutputStream
         final byte[] block = this.data.block;
         final int lastShadow = this.last;
 
-        for (int i = 256; --i >= 0;)
+        for (int i = 256; --i >= 0;) {
             inUse[i] = false;
+        }
 
         int rNToGo = 0;
         int rTPos = 0;

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZCompressorInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZCompressorInputStream.java?rev=1307765&r1=1307764&r2=1307765&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZCompressorInputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZCompressorInputStream.java
Sat Mar 31 10:59:47 2012
@@ -41,12 +41,15 @@ public class XZCompressorInputStream ext
      * @return  true if signature matches the .xz magic bytes, false otherwise
      */
     public static boolean matches(byte[] signature, int length) {
-        if (length < XZ.HEADER_MAGIC.length)
+        if (length < XZ.HEADER_MAGIC.length) {
             return false;
+        }
 
-        for (int i = 0; i < XZ.HEADER_MAGIC.length; ++i)
-            if (signature[i] != XZ.HEADER_MAGIC[i])
+        for (int i = 0; i < XZ.HEADER_MAGIC.length; ++i) {
+            if (signature[i] != XZ.HEADER_MAGIC[i]) {
                 return false;
+            }
+        }
 
         return true;
     }
@@ -89,10 +92,11 @@ public class XZCompressorInputStream ext
     public XZCompressorInputStream(InputStream inputStream,
                                    boolean decompressConcatenated)
             throws IOException {
-        if (decompressConcatenated)
+        if (decompressConcatenated) {
             in = new XZInputStream(inputStream);
-        else
+        } else {
             in = new SingleXZInputStream(inputStream);
+        }
     }
 
     /** {@inheritDoc} */



Mime
View raw message