Browse Source

Fix a complicated multi level nested if block structure to use a single level with multiple returns.

Change-Id: I3f116f37045e83aba5c80d45b987ab075502dcc6
stable-1.1
Ketan Padegaonkar 14 years ago committed by Shawn O. Pearce
parent
commit
8b8ad75ada
  1. 23
      org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java

23
org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java

@ -202,7 +202,8 @@ public class URIish implements Serializable {
if (matcher.matches()) { if (matcher.matches()) {
scheme = matcher.group(1); scheme = matcher.group(1);
path = cleanLeadingSlashes(matcher.group(2), scheme); path = cleanLeadingSlashes(matcher.group(2), scheme);
} else { return;
}
matcher = FULL_URI.matcher(s); matcher = FULL_URI.matcher(s);
if (matcher.matches()) { if (matcher.matches()) {
scheme = matcher.group(1); scheme = matcher.group(1);
@ -212,33 +213,31 @@ public class URIish implements Serializable {
if (matcher.group(5) != null) if (matcher.group(5) != null)
port = Integer.parseInt(matcher.group(5)); port = Integer.parseInt(matcher.group(5));
path = cleanLeadingSlashes( path = cleanLeadingSlashes(
n2e(matcher.group(6)) + n2e(matcher.group(7)), n2e(matcher.group(6)) + n2e(matcher.group(7)), scheme);
scheme); return;
} else { }
matcher = RELATIVE_SCP_URI.matcher(s); matcher = RELATIVE_SCP_URI.matcher(s);
if (matcher.matches()) { if (matcher.matches()) {
user = matcher.group(1); user = matcher.group(1);
pass = matcher.group(2); pass = matcher.group(2);
host = matcher.group(3); host = matcher.group(3);
path = matcher.group(4); path = matcher.group(4);
} else { return;
}
matcher = ABSOLUTE_SCP_URI.matcher(s); matcher = ABSOLUTE_SCP_URI.matcher(s);
if (matcher.matches()) { if (matcher.matches()) {
user = matcher.group(1); user = matcher.group(1);
pass = matcher.group(2); pass = matcher.group(2);
host = matcher.group(3); host = matcher.group(3);
path = matcher.group(4); path = matcher.group(4);
} else { return;
}
matcher = LOCAL_FILE.matcher(s); matcher = LOCAL_FILE.matcher(s);
if (matcher.matches()) { if (matcher.matches()) {
path = matcher.group(1); path = matcher.group(1);
} else return;
throw new URISyntaxException(s,
JGitText.get().cannotParseGitURIish);
}
}
}
} }
throw new URISyntaxException(s, JGitText.get().cannotParseGitURIish);
} }
private String n2e(String s) { private String n2e(String s) {

Loading…
Cancel
Save