commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1725161 - in /commons/proper/codec/trunk/src: main/java/org/apache/commons/codec/binary/ main/java/org/apache/commons/codec/language/ main/java/org/apache/commons/codec/language/bm/ main/java/org/apache/commons/codec/net/ test/java/org/apa...
Date Mon, 18 Jan 2016 01:08:57 GMT
Author: ggregory
Date: Mon Jan 18 01:08:56 2016
New Revision: 1725161

URL: http://svn.apache.org/viewvc?rev=1725161&view=rev
Log:
Statement unnecessarily nested within else clause.

Modified:
    commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32.java
    commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64.java
    commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/DaitchMokotoffSoundex.java
    commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/MatchRatingApproachEncoder.java
    commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/Nysiis.java
    commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/Rule.java
    commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/net/QuotedPrintableCodec.java
    commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Codec105ErrorInputStream.java
    commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineRegressionTest.java

Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32.java?rev=1725161&r1=1725160&r2=1725161&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32.java (original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32.java Mon
Jan 18 01:08:56 2016
@@ -348,21 +348,20 @@ public class Base32 extends BaseNCodec {
                 // We're done.
                 context.eof = true;
                 break;
-            } else {
-                final byte[] buffer = ensureBufferSize(decodeSize, context);
-                if (b >= 0 && b < this.decodeTable.length) {
-                    final int result = this.decodeTable[b];
-                    if (result >= 0) {
-                        context.modulus = (context.modulus+1) % BYTES_PER_ENCODED_BLOCK;
-                        // collect decoded bytes
-                        context.lbitWorkArea = (context.lbitWorkArea << BITS_PER_ENCODED_BYTE)
+ result;
-                        if (context.modulus == 0) { // we can output the 5 bytes
-                            buffer[context.pos++] = (byte) ((context.lbitWorkArea >>
32) & MASK_8BITS);
-                            buffer[context.pos++] = (byte) ((context.lbitWorkArea >>
24) & MASK_8BITS);
-                            buffer[context.pos++] = (byte) ((context.lbitWorkArea >>
16) & MASK_8BITS);
-                            buffer[context.pos++] = (byte) ((context.lbitWorkArea >>
8) & MASK_8BITS);
-                            buffer[context.pos++] = (byte) (context.lbitWorkArea & MASK_8BITS);
-                        }
+            }
+            final byte[] buffer = ensureBufferSize(decodeSize, context);
+            if (b >= 0 && b < this.decodeTable.length) {
+                final int result = this.decodeTable[b];
+                if (result >= 0) {
+                    context.modulus = (context.modulus+1) % BYTES_PER_ENCODED_BLOCK;
+                    // collect decoded bytes
+                    context.lbitWorkArea = (context.lbitWorkArea << BITS_PER_ENCODED_BYTE)
+ result;
+                    if (context.modulus == 0) { // we can output the 5 bytes
+                        buffer[context.pos++] = (byte) ((context.lbitWorkArea >> 32)
& MASK_8BITS);
+                        buffer[context.pos++] = (byte) ((context.lbitWorkArea >> 24)
& MASK_8BITS);
+                        buffer[context.pos++] = (byte) ((context.lbitWorkArea >> 16)
& MASK_8BITS);
+                        buffer[context.pos++] = (byte) ((context.lbitWorkArea >> 8)
& MASK_8BITS);
+                        buffer[context.pos++] = (byte) (context.lbitWorkArea & MASK_8BITS);
                     }
                 }
             }

Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64.java?rev=1725161&r1=1725160&r2=1725161&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64.java (original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64.java Mon
Jan 18 01:08:56 2016
@@ -441,17 +441,16 @@ public class Base64 extends BaseNCodec {
                 // We're done.
                 context.eof = true;
                 break;
-            } else {
-                if (b >= 0 && b < DECODE_TABLE.length) {
-                    final int result = DECODE_TABLE[b];
-                    if (result >= 0) {
-                        context.modulus = (context.modulus+1) % BYTES_PER_ENCODED_BLOCK;
-                        context.ibitWorkArea = (context.ibitWorkArea << BITS_PER_ENCODED_BYTE)
+ result;
-                        if (context.modulus == 0) {
-                            buffer[context.pos++] = (byte) ((context.ibitWorkArea >>
16) & MASK_8BITS);
-                            buffer[context.pos++] = (byte) ((context.ibitWorkArea >>
8) & MASK_8BITS);
-                            buffer[context.pos++] = (byte) (context.ibitWorkArea & MASK_8BITS);
-                        }
+            }
+            if (b >= 0 && b < DECODE_TABLE.length) {
+                final int result = DECODE_TABLE[b];
+                if (result >= 0) {
+                    context.modulus = (context.modulus+1) % BYTES_PER_ENCODED_BLOCK;
+                    context.ibitWorkArea = (context.ibitWorkArea << BITS_PER_ENCODED_BYTE)
+ result;
+                    if (context.modulus == 0) {
+                        buffer[context.pos++] = (byte) ((context.ibitWorkArea >> 16)
& MASK_8BITS);
+                        buffer[context.pos++] = (byte) ((context.ibitWorkArea >> 8)
& MASK_8BITS);
+                        buffer[context.pos++] = (byte) (context.ibitWorkArea & MASK_8BITS);
                     }
                 }
             }

Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/DaitchMokotoffSoundex.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/DaitchMokotoffSoundex.java?rev=1725161&r1=1725160&r2=1725161&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/DaitchMokotoffSoundex.java
(original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/DaitchMokotoffSoundex.java
Mon Jan 18 01:08:56 2016
@@ -286,42 +286,40 @@ public class DaitchMokotoffSoundex imple
                     if (parts.length != 2) {
                         throw new IllegalArgumentException("Malformed folding statement split
into " + parts.length +
                                 " parts: " + rawLine + " in " + location);
-                    } else {
-                        final String leftCharacter = parts[0];
-                        final String rightCharacter = parts[1];
-
-                        if (leftCharacter.length() != 1 || rightCharacter.length() != 1)
{
-                            throw new IllegalArgumentException("Malformed folding statement
- " +
-                                    "patterns are not single characters: " + rawLine + "
in " + location);
-                        }
+                    }
+                    final String leftCharacter = parts[0];
+                    final String rightCharacter = parts[1];
 
-                        asciiFoldings.put(leftCharacter.charAt(0), rightCharacter.charAt(0));
+                    if (leftCharacter.length() != 1 || rightCharacter.length() != 1) {
+                        throw new IllegalArgumentException("Malformed folding statement -
" +
+                                "patterns are not single characters: " + rawLine + " in "
+ location);
                     }
+
+                    asciiFoldings.put(leftCharacter.charAt(0), rightCharacter.charAt(0));
                 } else {
                     // rule
                     final String[] parts = line.split("\\s+");
                     if (parts.length != 4) {
                         throw new IllegalArgumentException("Malformed rule statement split
into " + parts.length +
                                 " parts: " + rawLine + " in " + location);
-                    } else {
-                        try {
-                            final String pattern = stripQuotes(parts[0]);
-                            final String replacement1 = stripQuotes(parts[1]);
-                            final String replacement2 = stripQuotes(parts[2]);
-                            final String replacement3 = stripQuotes(parts[3]);
+                    }
+                    try {
+                        final String pattern = stripQuotes(parts[0]);
+                        final String replacement1 = stripQuotes(parts[1]);
+                        final String replacement2 = stripQuotes(parts[2]);
+                        final String replacement3 = stripQuotes(parts[3]);
 
-                            final Rule r = new Rule(pattern, replacement1, replacement2,
replacement3);
-                            final char patternKey = r.pattern.charAt(0);
-                            List<Rule> rules = ruleMapping.get(patternKey);
-                            if (rules == null) {
-                                rules = new ArrayList<Rule>();
-                                ruleMapping.put(patternKey, rules);
-                            }
-                            rules.add(r);
-                        } catch (final IllegalArgumentException e) {
-                            throw new IllegalStateException(
-                                    "Problem parsing line '" + currentLine + "' in " + location,
e);
+                        final Rule r = new Rule(pattern, replacement1, replacement2, replacement3);
+                        final char patternKey = r.pattern.charAt(0);
+                        List<Rule> rules = ruleMapping.get(patternKey);
+                        if (rules == null) {
+                            rules = new ArrayList<Rule>();
+                            ruleMapping.put(patternKey, rules);
                         }
+                        rules.add(r);
+                    } catch (final IllegalArgumentException e) {
+                        throw new IllegalStateException(
+                                "Problem parsing line '" + currentLine + "' in " + location,
e);
                     }
                 }
             }

Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/MatchRatingApproachEncoder.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/MatchRatingApproachEncoder.java?rev=1725161&r1=1725160&r2=1725161&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/MatchRatingApproachEncoder.java
(original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/MatchRatingApproachEncoder.java
Mon Jan 18 01:08:56 2016
@@ -163,9 +163,8 @@ public class MatchRatingApproachEncoder
             final String firstThree = name.substring(0, THREE);
             final String lastThree = name.substring(nameLength - THREE, nameLength);
             return firstThree + lastThree;
-        } else {
-            return name;
         }
+        return name;
     }
 
     /**
@@ -335,9 +334,8 @@ public class MatchRatingApproachEncoder
         // Final bit - subtract longest string from 6 and return this int value
         if (strA.length() > strB.length()) {
             return Math.abs(SIX - strA.length());
-        } else {
-            return Math.abs(SIX - strB.length());
         }
+        return Math.abs(SIX - strB.length());
     }
 
     /**
@@ -419,8 +417,7 @@ public class MatchRatingApproachEncoder
         // return isVowel(firstLetter) ? (firstLetter + name) : name;
         if (isVowel(firstLetter)) {
             return firstLetter + name;
-        } else {
-            return name;
         }
+        return name;
     }
 }

Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/Nysiis.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/Nysiis.java?rev=1725161&r1=1725160&r2=1725161&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/Nysiis.java
(original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/Nysiis.java
Mon Jan 18 01:08:56 2016
@@ -139,9 +139,8 @@ public class Nysiis implements StringEnc
         if (curr == 'K') {
             if (next == 'N') {
                 return CHARS_NN;
-            } else {
-                return CHARS_C;
             }
+            return CHARS_C;
         }
 
         // 4. SCH -> SSS

Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/Rule.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/Rule.java?rev=1725161&r1=1725160&r2=1725161&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/Rule.java
(original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/Rule.java
Mon Jan 18 01:08:56 2016
@@ -373,9 +373,8 @@ public class Rule {
             final Set<String> langs = new HashSet<String>(Arrays.asList(in.split("[+]")));
 
             return new Phoneme(before, Languages.LanguageSet.from(langs));
-        } else {
-            return new Phoneme(ph, Languages.ANY_LANGUAGE);
         }
+        return new Phoneme(ph, Languages.ANY_LANGUAGE);
     }
 
     private static PhonemeExpr parsePhonemeExpr(final String ph) {
@@ -394,9 +393,8 @@ public class Rule {
             }
 
             return new PhonemeList(phs);
-        } else {
-            return parsePhoneme(ph);
         }
+        return parsePhoneme(ph);
     }
 
     private static Map<String, List<Rule>> parseRules(final Scanner scanner,
final String location) {
@@ -436,50 +434,48 @@ public class Rule {
                         if (incl.contains(" ")) {
                             throw new IllegalArgumentException("Malformed import statement
'" + rawLine + "' in " +
                                                                location);
-                        } else {
-                            lines.putAll(parseRules(createScanner(incl), location + "->"
+ incl));
                         }
+                        lines.putAll(parseRules(createScanner(incl), location + "->" +
incl));
                     } else {
                         // rule
                         final String[] parts = line.split("\\s+");
                         if (parts.length != 4) {
                             throw new IllegalArgumentException("Malformed rule statement
split into " + parts.length +
                                                                " parts: " + rawLine + " in
" + location);
-                        } else {
-                            try {
-                                final String pat = stripQuotes(parts[0]);
-                                final String lCon = stripQuotes(parts[1]);
-                                final String rCon = stripQuotes(parts[2]);
-                                final PhonemeExpr ph = parsePhonemeExpr(stripQuotes(parts[3]));
-                                final int cLine = currentLine;
-                                final Rule r = new Rule(pat, lCon, rCon, ph) {
-                                    private final int myLine = cLine;
-                                    private final String loc = location;
-
-                                    @Override
-                                    public String toString() {
-                                        final StringBuilder sb = new StringBuilder();
-                                        sb.append("Rule");
-                                        sb.append("{line=").append(myLine);
-                                        sb.append(", loc='").append(loc).append('\'');
-                                        sb.append(", pat='").append(pat).append('\'');
-                                        sb.append(", lcon='").append(lCon).append('\'');
-                                        sb.append(", rcon='").append(rCon).append('\'');
-                                        sb.append('}');
-                                        return sb.toString();
-                                    }
-                                };
-                                final String patternKey = r.pattern.substring(0,1);
-                                List<Rule> rules = lines.get(patternKey);
-                                if (rules == null) {
-                                    rules = new ArrayList<Rule>();
-                                    lines.put(patternKey, rules);
+                        }
+                        try {
+                            final String pat = stripQuotes(parts[0]);
+                            final String lCon = stripQuotes(parts[1]);
+                            final String rCon = stripQuotes(parts[2]);
+                            final PhonemeExpr ph = parsePhonemeExpr(stripQuotes(parts[3]));
+                            final int cLine = currentLine;
+                            final Rule r = new Rule(pat, lCon, rCon, ph) {
+                                private final int myLine = cLine;
+                                private final String loc = location;
+
+                                @Override
+                                public String toString() {
+                                    final StringBuilder sb = new StringBuilder();
+                                    sb.append("Rule");
+                                    sb.append("{line=").append(myLine);
+                                    sb.append(", loc='").append(loc).append('\'');
+                                    sb.append(", pat='").append(pat).append('\'');
+                                    sb.append(", lcon='").append(lCon).append('\'');
+                                    sb.append(", rcon='").append(rCon).append('\'');
+                                    sb.append('}');
+                                    return sb.toString();
                                 }
-                                rules.add(r);
-                            } catch (final IllegalArgumentException e) {
-                                throw new IllegalStateException("Problem parsing line '"
+ currentLine + "' in " +
-                                                                location, e);
+                            };
+                            final String patternKey = r.pattern.substring(0,1);
+                            List<Rule> rules = lines.get(patternKey);
+                            if (rules == null) {
+                                rules = new ArrayList<Rule>();
+                                lines.put(patternKey, rules);
                             }
+                            rules.add(r);
+                        } catch (final IllegalArgumentException e) {
+                            throw new IllegalStateException("Problem parsing line '" + currentLine
+ "' in " +
+                                                            location, e);
                         }
                     }
                 }
@@ -513,14 +509,13 @@ public class Rule {
                             return input.length() == 0;
                         }
                     };
-                } else {
-                    return new RPattern() {
-                        @Override
-                        public boolean isMatch(final CharSequence input) {
-                            return input.equals(content);
-                        }
-                    };
                 }
+                return new RPattern() {
+                    @Override
+                    public boolean isMatch(final CharSequence input) {
+                        return input.equals(content);
+                    }
+                };
             } else if ((startsWith || endsWith) && content.length() == 0) {
                 // matches every string
                 return ALL_STRINGS_RMATCHER;

Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/net/QuotedPrintableCodec.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/net/QuotedPrintableCodec.java?rev=1725161&r1=1725160&r2=1725161&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/net/QuotedPrintableCodec.java
(original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/net/QuotedPrintableCodec.java
Mon Jan 18 01:08:56 2016
@@ -221,10 +221,9 @@ public class QuotedPrintableCodec implem
                                   final ByteArrayOutputStream buffer) {
         if (encode) {
             return encodeQuotedPrintable(b, buffer);
-        } else {
-            buffer.write(b);
-            return 1;
         }
+        buffer.write(b);
+        return 1;
     }
 
     /**

Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Codec105ErrorInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Codec105ErrorInputStream.java?rev=1725161&r1=1725160&r2=1725161&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Codec105ErrorInputStream.java
(original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Codec105ErrorInputStream.java
Mon Jan 18 01:08:56 2016
@@ -37,9 +37,8 @@ public class Codec105ErrorInputStream ex
     public int read() throws IOException {
         if (this.countdown-- > 0) {
             return '\n';
-        } else {
-            return EOF;
         }
+        return EOF;
     }
 
     @Override
@@ -47,8 +46,7 @@ public class Codec105ErrorInputStream ex
         if (this.countdown-- > 0) {
             b[pos] = '\n';
             return 1;
-        } else {
-            return EOF;
         }
+        return EOF;
     }
 }

Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineRegressionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineRegressionTest.java?rev=1725161&r1=1725160&r2=1725161&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineRegressionTest.java
(original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineRegressionTest.java
Mon Jan 18 01:08:56 2016
@@ -237,8 +237,7 @@ public class PhoneticEngineRegressionTes
         */
         if (languageSet == null) {
             return engine.encode(input);
-        } else {
-            return engine.encode(input, languageSet);
         }
+        return engine.encode(input, languageSet);
     }
 }



Mime
View raw message