Author: britter Date: Fri Dec 26 12:44:11 2014 New Revision: 1647967 URL: http://svn.apache.org/r1647967 Log: PMD: Combine nested if statements
Modified: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java Modified: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java?rev=1647967&r1=1647966&r2=1647967&view=diff ============================================================================== --- commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java (original) +++ commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java Fri Dec 26 12:44:11 2014 @@ -339,11 +339,8 @@ public class UrlValidator implements Ser return false; } - if (isOff(ALLOW_ALL_SCHEMES)) { - - if (!allowedSchemes.contains(scheme)) { - return false; - } + if (isOff(ALLOW_ALL_SCHEMES) && !allowedSchemes.contains(scheme)) { + return false; } return true; @@ -361,10 +358,8 @@ public class UrlValidator implements Ser } // check manual authority validation if specified - if (authorityValidator != null) { - if (authorityValidator.isValid(authority)) { - return true; - } + if (authorityValidator != null && authorityValidator.isValid(authority)) { + return true; } Matcher authorityMatcher = AUTHORITY_PATTERN.matcher(authority); @@ -387,10 +382,8 @@ public class UrlValidator implements Ser } String port = authorityMatcher.group(PARSE_AUTHORITY_PORT); - if (port != null) { - if (!PORT_PATTERN.matcher(port).matches()) { - return false; - } + if (port != null && !PORT_PATTERN.matcher(port).matches()) { + return false; } String extra = authorityMatcher.group(PARSE_AUTHORITY_EXTRA); @@ -422,10 +415,8 @@ public class UrlValidator implements Ser int slashCount = countToken("/", path); int dot2Count = countToken("..", path); - if (dot2Count > 0) { - if ((slashCount - slash2Count - 1) <= dot2Count) { - return false; - } + if (dot2Count > 0 && (slashCount - slash2Count - 1) <= dot2Count) { + return false; } return true;