directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject directory-kerby git commit: Applying some simplifications thrown up by PMD
Date Fri, 17 Apr 2015 14:19:30 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/master 6b71401ab -> ce1e7c473


Applying some simplifications thrown up by PMD


Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/ce1e7c47
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/ce1e7c47
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/ce1e7c47

Branch: refs/heads/master
Commit: ce1e7c4733151833ce8627431d934b428e05ca9c
Parents: 6b71401
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Fri Apr 17 15:18:57 2015 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Fri Apr 17 15:18:57 2015 +0100

----------------------------------------------------------------------
 .../kerby/asn1/type/AbstractAsn1Type.java       |  9 ++++----
 .../apache/kerby/asn1/type/Asn1Collection.java  |  1 -
 .../kerby/asn1/type/Asn1CollectionType.java     |  1 -
 .../kerby/asn1/type/Asn1NumericsString.java     | 14 ++++--------
 .../apache/kerby/asn1/type/Asn1SequenceOf.java  |  2 +-
 .../org/apache/kerby/asn1/type/Asn1String.java  |  2 +-
 .../org/apache/kerby/asn1/type/Asn1Tagging.java |  1 -
 .../org/apache/kerby/asn1/type/Asn1Type.java    | 24 ++++++++++----------
 .../src/main/java/org/apache/kerby/KOption.java | 18 +++++++--------
 .../main/java/org/apache/kerby/util/Base64.java |  6 ++---
 10 files changed, 35 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ce1e7c47/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/AbstractAsn1Type.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/AbstractAsn1Type.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/AbstractAsn1Type.java
index bf0ec9b..7ccfa18 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/AbstractAsn1Type.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/AbstractAsn1Type.java
@@ -311,7 +311,6 @@ public abstract class AbstractAsn1Type<T> implements Asn1Type {
     public static Asn1Item decodeOne(LimitedByteBuffer content) throws IOException {
         int tag = readTag(content);
         int tagNo = readTagNo(content, tag);
-        boolean isConstructed = EncodingOption.isConstructed(tag);
         int length = readLength(content);
         if (length < 0) {
             throw new IOException("Unexpected length");
@@ -328,7 +327,7 @@ public abstract class AbstractAsn1Type<T> implements Asn1Type {
 
     public static void skipOne(LimitedByteBuffer content) throws IOException {
         int tag = readTag(content);
-        int tagNo = readTagNo(content, tag);
+        readTagNo(content, tag);
         int length = readLength(content);
         if (length < 0) {
             throw new IOException("Unexpected length");
@@ -431,13 +430,13 @@ public abstract class AbstractAsn1Type<T> implements Asn1Type
{
                 throw new IOException("Invalid high tag number found");
             }
 
-            while ((b >= 0) && ((b & 0x80) != 0)) {
-                tagNo |= (b & 0x7f);
+            while (b >= 0 && (b & 0x80) != 0) {
+                tagNo |= b & 0x7f;
                 tagNo <<= 7;
                 b = buffer.readByte();
             }
 
-            tagNo |= (b & 0x7f);
+            tagNo |= b & 0x7f;
         }
 
         return tagNo;

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ce1e7c47/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Collection.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Collection.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Collection.java
index 796092e..158cd02 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Collection.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Collection.java
@@ -19,7 +19,6 @@
  */
 package org.apache.kerby.asn1.type;
 
-import org.apache.kerby.asn1.EncodingOption;
 import org.apache.kerby.asn1.LimitedByteBuffer;
 import org.apache.kerby.asn1.TagClass;
 import org.apache.kerby.asn1.UniversalTag;

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ce1e7c47/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1CollectionType.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1CollectionType.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1CollectionType.java
index bb42988..7e09268 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1CollectionType.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1CollectionType.java
@@ -19,7 +19,6 @@
  */
 package org.apache.kerby.asn1.type;
 
-import org.apache.kerby.asn1.EncodingOption;
 import org.apache.kerby.asn1.LimitedByteBuffer;
 import org.apache.kerby.asn1.TagClass;
 import org.apache.kerby.asn1.TaggingOption;

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ce1e7c47/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1NumericsString.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1NumericsString.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1NumericsString.java
index ea534ac..1c315d4 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1NumericsString.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1NumericsString.java
@@ -29,21 +29,17 @@ public class Asn1NumericsString extends Asn1String
 
     public Asn1NumericsString(String value) {
         super(UniversalTag.NUMERIC_STRING, value);
-        if (value != null) {
-            if (!isNumeric(value)) {
-                throw new IllegalArgumentException("Invalid numeric string");
-            }
+        if (value != null && !isNumeric(value)) {
+             throw new IllegalArgumentException("Invalid numeric string");
         }
     }
 
     public static boolean isNumeric(String  s) {
-        char c;
         for (int i = s.length() - 1; i >= 0; i--) {
-            c = s.charAt(i);
-            if ((c >= '0' && c <= '9') || c == ' ') {
-                continue;
+            char c = s.charAt(i);
+            if (!(c >= '0' && c <= '9' || c == ' ')) {
+                return false;
             }
-            return false;
         }
         return true;
     }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ce1e7c47/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1SequenceOf.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1SequenceOf.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1SequenceOf.java
index dcf6356..d337fa2 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1SequenceOf.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1SequenceOf.java
@@ -29,7 +29,7 @@ public class Asn1SequenceOf<T extends Asn1Type> extends Asn1CollectionOf<T>
     }
 
     public boolean isEmpty() {
-        return (getValue() == null || getElements().size() == 0);
+        return getValue() == null || getElements().size() == 0;
     }
 
     public void add(T element) {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ce1e7c47/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1String.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1String.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1String.java
index 3f75d07..f056555 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1String.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1String.java
@@ -156,7 +156,7 @@ public abstract class Asn1String extends Asn1Simple<String>
                 if (W1 > 0xDBFF) {
                     throw new IllegalStateException("invalid UTF-16 codepoint");
                 }
-                int codePoint = (((W1 & 0x03FF) << 10) | (W2 & 0x03FF)) + 0x10000;
+                int codePoint = ((W1 & 0x03FF) << 10) | (W2 & 0x03FF) + 0x10000;
                 sOut.write(0xf0 | (codePoint >> 18));
                 sOut.write(0x80 | ((codePoint >> 12) & 0x3F));
                 sOut.write(0x80 | ((codePoint >> 6) & 0x3F));

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ce1e7c47/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Tagging.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Tagging.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Tagging.java
index 89fccaa..63c9f53 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Tagging.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Tagging.java
@@ -19,7 +19,6 @@
  */
 package org.apache.kerby.asn1.type;
 
-import org.apache.kerby.asn1.EncodingOption;
 import org.apache.kerby.asn1.LimitedByteBuffer;
 import org.apache.kerby.asn1.TagClass;
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ce1e7c47/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Type.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Type.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Type.java
index 95f8855..3ddd16f 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Type.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Type.java
@@ -33,67 +33,67 @@ public interface Asn1Type {
      *
      * @return
      */
-    public int tagFlags();
+    int tagFlags();
 
     /**
      * Get tag number for the type
      * @return tag number
      */
-    public int tagNo();
+    int tagNo();
 
     /**
      * Set encoding option.
      * See {@link org.apache.kerby.asn1.EncodingOption}.
      * @param encodingOption
      */
-    public void setEncodingOption(EncodingOption encodingOption);
+    void setEncodingOption(EncodingOption encodingOption);
 
     /**
      * Get length of encoding bytes by just calculating without real encoding.
      * Generally it's called to prepare for the encoding buffer.
      * @return length of encoding bytes
      */
-    public int encodingLength();
+    int encodingLength();
 
     /**
      * Encode the type, by recursively.
      * @return encoded bytes
      */
-    public byte[] encode();
+    byte[] encode();
 
     /**
      * Encode the type, by recursively, using the provided buffer.
      * @param buffer
      */
-    public void encode(ByteBuffer buffer);
+    void encode(ByteBuffer buffer);
 
     /**
      * Decode the content bytes into this type.
      * @param content
      * @throws IOException
      */
-    public void decode(byte[] content) throws IOException;
+    void decode(byte[] content) throws IOException;
 
     /**
      * Decode the content bytes into this type.
      * @param content
      * @throws IOException
      */
-    public void decode(ByteBuffer content) throws IOException;
+    void decode(ByteBuffer content) throws IOException;
 
     /**
      * Tag and encode this type using the provided tagging option.
      * @param taggingOption
      * @return encoded bytes
      */
-    public byte[] taggedEncode(TaggingOption taggingOption);
+    byte[] taggedEncode(TaggingOption taggingOption);
 
     /**
      * Tag and encode this type using the provided tagging option.
      * @param taggingOption
      * @return encoded bytes
      */
-    public void taggedEncode(ByteBuffer buffer, TaggingOption taggingOption);
+    void taggedEncode(ByteBuffer buffer, TaggingOption taggingOption);
 
     /**
      * Decode the content bytes into this type as it's tagged with the provided
@@ -105,7 +105,7 @@ public interface Asn1Type {
      * @param taggingOption
      * @throws IOException
      */
-    public void taggedDecode(ByteBuffer content, TaggingOption taggingOption) throws IOException;
+    void taggedDecode(ByteBuffer content, TaggingOption taggingOption) throws IOException;
 
     /**
      * Decode the content bytes into this type as it's tagged with the provided
@@ -117,5 +117,5 @@ public interface Asn1Type {
      * @param taggingOption
      * @throws IOException
      */
-    public void taggedDecode(byte[] content, TaggingOption taggingOption) throws IOException;
+    void taggedDecode(byte[] content, TaggingOption taggingOption) throws IOException;
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ce1e7c47/lib/kerby-util/src/main/java/org/apache/kerby/KOption.java
----------------------------------------------------------------------
diff --git a/lib/kerby-util/src/main/java/org/apache/kerby/KOption.java b/lib/kerby-util/src/main/java/org/apache/kerby/KOption.java
index 52f185d..3809232 100644
--- a/lib/kerby-util/src/main/java/org/apache/kerby/KOption.java
+++ b/lib/kerby-util/src/main/java/org/apache/kerby/KOption.java
@@ -21,21 +21,21 @@ package org.apache.kerby;
 
 public interface KOption {
 
-    public void setType(KOptionType type);
+    void setType(KOptionType type);
 
-    public KOptionType getType();
+    KOptionType getType();
 
-    public String getOptionName();
+    String getOptionName();
 
-    public void setName(String name);
+    void setName(String name);
 
-    public String getName();
+    String getName();
 
-    public void setDescription(String description);
+    void setDescription(String description);
 
-    public String getDescription();
+    String getDescription();
 
-    public void setValue(Object value);
+    void setValue(Object value);
 
-    public Object getValue();
+    Object getValue();
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ce1e7c47/lib/kerby-util/src/main/java/org/apache/kerby/util/Base64.java
----------------------------------------------------------------------
diff --git a/lib/kerby-util/src/main/java/org/apache/kerby/util/Base64.java b/lib/kerby-util/src/main/java/org/apache/kerby/util/Base64.java
index 0a49ccb..67f7929 100644
--- a/lib/kerby-util/src/main/java/org/apache/kerby/util/Base64.java
+++ b/lib/kerby-util/src/main/java/org/apache/kerby/util/Base64.java
@@ -589,7 +589,7 @@ public class Base64 {
      * @since 1.4
      */
     public static boolean isBase64(byte octet) {
-        return octet == PAD || (octet >= 0 && octet < DECODE_TABLE.length &&
DECODE_TABLE[octet] != -1);
+        return octet == PAD || octet >= 0 && octet < DECODE_TABLE.length &&
DECODE_TABLE[octet] != -1;
     }
 
     /**
@@ -1013,7 +1013,7 @@ public class Base64 {
         bitlen = ((bitlen + 7) >> 3) << 3;
         byte[] bigBytes = bigInt.toByteArray();
 
-        if (((bigInt.bitLength() % 8) != 0) && (((bigInt.bitLength() / 8) + 1) ==
(bitlen / 8))) {
+        if (bigInt.bitLength() % 8 != 0 && (bigInt.bitLength() / 8 + 1) == bitlen
/ 8) {
             return bigBytes;
         }
         // set up params for copying everything but sign bit
@@ -1021,7 +1021,7 @@ public class Base64 {
         int len = bigBytes.length;
 
         // if bigInt is exactly byte-aligned, just skip signbit in copy
-        if ((bigInt.bitLength() % 8) == 0) {
+        if (bigInt.bitLength() % 8 == 0) {
             startSrc = 1;
             len--;
         }


Mime
View raw message