commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject [lang] PMD: Nested if statements can be combined
Date Mon, 17 Apr 2017 11:03:10 GMT
Repository: commons-lang
Updated Branches:
  refs/heads/master fb4803623 -> c82b1f062


PMD: Nested if statements can be combined


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

Branch: refs/heads/master
Commit: c82b1f062af2a1a376e514020707597f6ed1f82d
Parents: fb48036
Author: Benedikt Ritter <britter@apache.org>
Authored: Mon Apr 17 13:00:37 2017 +0200
Committer: Benedikt Ritter <britter@apache.org>
Committed: Mon Apr 17 13:02:11 2017 +0200

----------------------------------------------------------------------
 .../java/org/apache/commons/lang3/RandomStringUtils.java  | 10 ++++------
 .../org/apache/commons/lang3/reflect/MethodUtils.java     |  6 ++----
 2 files changed, 6 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/c82b1f06/src/main/java/org/apache/commons/lang3/RandomStringUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/RandomStringUtils.java b/src/main/java/org/apache/commons/lang3/RandomStringUtils.java
index ec62d50..ba42d36 100644
--- a/src/main/java/org/apache/commons/lang3/RandomStringUtils.java
+++ b/src/main/java/org/apache/commons/lang3/RandomStringUtils.java
@@ -372,12 +372,10 @@ public class RandomStringUtils {
         final int zero_digit_ascii = 48;
         final int first_letter_ascii = 65;
 
-        if (chars == null) {
-            if (numbers && end <= zero_digit_ascii
-                    || letters && end <= first_letter_ascii) {
-                throw new IllegalArgumentException("Parameter end (" + end + ") must be greater
then (" + zero_digit_ascii + ") for generating digits " +
-                        "or greater then (" + first_letter_ascii + ") for generating letters.");
-            }
+        if (chars == null && (numbers && end <= zero_digit_ascii
+                || letters && end <= first_letter_ascii)) {
+            throw new IllegalArgumentException("Parameter end (" + end + ") must be greater
then (" + zero_digit_ascii + ") for generating digits " +
+                    "or greater then (" + first_letter_ascii + ") for generating letters.");
         }
 
         StringBuilder builder = new StringBuilder(count);

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/c82b1f06/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
index 4602378..c6f9795 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
@@ -211,10 +211,8 @@ public class MethodUtils {
             messagePrefix = "No such method: ";
             method = getMatchingMethod(object.getClass(),
                     methodName, parameterTypes);
-            if (method != null) {
-                if (!method.isAccessible()) {
-                    method.setAccessible(true);
-                }
+            if (method != null && !method.isAccessible()) {
+                method.setAccessible(true);
             }
         } else {
             messagePrefix = "No such accessible method: ";


Mime
View raw message