File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/extension/Extension.java | File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/ssh/Directory.java | |||
Method name: String[] split(String, String)
|
Method name: String[] getPath(String)
|
|||
Number of AST nodes: 2 | Number of AST nodes: 3 | |||
1 | /** | 1 | /** | |
2 | * Splits the string on every token into an array of strings. | 2 | * Convert a file path to an array of path components. | |
3 | * | 3 | * This uses File.sepatator to split the file path string. | |
4 | * @param string the string | 4 | * @param thePath the file path string to convert | |
5 | * @param onToken the token | 5 | * @return an array of path components | |
6 | * @return the resultant array | 6 | */ | |
7 | */ | 7 | public static String[] getPath(String thePath) { | |
8 | private static String[] split(final String string, | 8 | StringTokenizer tokenizer = new StringTokenizer(thePath, | |
9 | final String onToken) { | 9 | File.separator); | |
10 | final StringTokenizer tokenizer = new StringTokenizer(string, onToken); | 10 | String[] path = new String[ tokenizer.countTokens() ]; | |
11 | final String[] result = new String[ tokenizer.countTokens() ]; | 11 | ||
12 | 12 | int i = 0; | ||
13 | for (int i = 0; i < result.length; i++) { | 13 | while (tokenizer.hasMoreTokens()) { | |
14 | result[ i ] = tokenizer.nextToken(); | 14 | path[i] = tokenizer.nextToken(); | |
15 | } | 15 | i++; | |
16 | 16 | } | ||
17 | return result; | 17 | ||
18 | } | 18 | return path; | |
19 | } | |||
See real code fragment | See real code fragment |
Number of mapped statements | 4 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 0.0 |
Similarity Score | 1.000 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3 | for (int i = 0; i < result.length; i++) |
| 4 | while (tokenizer.hasMoreTokens()) | ||||||||||||||||||
4 | result[i] = tokenizer.nextToken(); |
| 5 | path[i] = tokenizer.nextToken(); | ||||||||||||||||||
|
| 6 | i++; |
Row | Violation |
---|---|
1 | Type java.lang.String[] of variable result does not match with type java.lang.String of variable thePath |
2 | Type java.lang.String[] of variable result does not match with type java.lang.String of variable thePath |
3 | Unmatched statement i++; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |