File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/Copy.java | File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/Copy.java | |||
Method name: void doFileOperations()
|
Method name: void doResourceOperations(Map)
|
|||
Number of AST nodes: 12 | Number of AST nodes: 10 | |||
1 | String toFile = toFiles[i];↵ | |||
2 | if (fromFile.equals(toFile)) {↵ | |||
3 | log("Skipping self-copy of " + fromFile, verbosity);↵ | |||
4 | continue;↵ | |||
5 | }↵ | 1 | for (int i = 0; i < toFiles.length; i++) {↵ | |
2 | String toFile = toFiles[i];↵ | |||
6 | try {↵ | 3 | try {↵ | |
7 | log("Copying " + fromFile + " to " + toFile,↵ | 4 | log("Copying " + fromResource + " to " + toFile,↵ | |
8 | verbosity);↵ | 5 | verbosity);↵ | |
9 | FilterSetCollection executionFilters =↵ | 6 | FilterSetCollection executionFilters =↵ | |
10 | new FilterSetCollection();↵ | 7 | new FilterSetCollection();↵ | |
11 | if (filtering) {↵ | 8 | if (filtering) {↵ | |
12 | executionFilters↵ | 9 | executionFilters↵ | |
13 | .addFilterSet(getProject().getGlobalFilterSet());↵ | 10 | .addFilterSet(getProject().getGlobalFilterSet());↵ | |
14 | }↵ | 11 | }↵ | |
15 | for (Enumeration filterEnum = filterSets.elements();↵ | 12 | for (Enumeration filterEnum = filterSets.elements();↵ | |
16 | filterEnum.hasMoreElements();) {↵ | 13 | filterEnum.hasMoreElements();) {↵ | |
17 | executionFilters↵ | 14 | executionFilters↵ | |
18 | .addFilterSet((FilterSet) filterEnum.nextElement());↵ | 15 | .addFilterSet((FilterSet) filterEnum.nextElement());↵ | |
19 | }↵ | 16 | }↵ | |
20 | fileUtils.copyFile(fromFile, toFile,↵ | 17 | ResourceUtils.copyResource(fromResource,↵ | |
18 | new FileResource(destDir,↵ | |||
19 | toFile),↵ | |||
21 | executionFilters,↵ | 20 | executionFilters,↵ | |
22 | filterChains,↵ | 21 | filterChains,↵ | |
23 | forceOverwrite,↵ | 22 | forceOverwrite,↵ | |
24 | preserveLastModified,↵ | 23 | preserveLastModified,↵ | |
25 | inputEncoding,↵ | 24 | inputEncoding,↵ | |
26 | outputEncoding,↵ | 25 | outputEncoding,↵ | |
27 | getProject());↵ | 26 | getProject());↵ | |
28 | } catch (IOException ioe) {↵ | 27 | } catch (IOException ioe) {↵ | |
29 | String msg = "Failed to copy " + fromFile↵ | 28 | String msg = "Failed to copy " + fromResource↵ | |
30 | + " to " + toFile↵ | 29 | + " to " + toFile↵ | |
31 | + " due to " + getDueTo(ioe);↵ | 30 | + " due to " + getDueTo(ioe);↵ | |
32 | File targetFile = new File(toFile);↵ | 31 | File targetFile = new File(toFile);↵ | |
33 | if (targetFile.exists() && !targetFile.delete()) {↵ | 32 | if (targetFile.exists() && !targetFile.delete()) {↵ | |
34 | msg += " and I couldn't delete the corrupt " + toFile;↵ | 33 | msg += " and I couldn't delete the corrupt " + toFile;↵ | |
35 | }↵ | 34 | }↵ | |
36 | if (failonerror) {↵ | 35 | if (failonerror) {↵ | |
37 | throw new BuildException(msg, ioe, getLocation());↵ | 36 | throw new BuildException(msg, ioe, getLocation());↵ | |
38 | }↵ | 37 | }↵ | |
39 | log(msg, Project.MSG_ERR);↵ | 38 | log(msg, Project.MSG_ERR);↵ | |
40 | } | 39 | }↵ | |
40 |
| |||
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 1.8 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 34 |
Number of mapped statements | 8 |
Number of unmapped statements in the first code fragment | 4 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 8.9 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8 | String toFile = toFiles[i]; | 8 | String toFile = toFiles[i]; | |||||||||||||||
9 | if (fromFile.equals(toFile)) |
| | |||||||||||||||
10 | log("Skipping self-copy of " + fromFile, verbosity); | | ||||||||||||||||
11 | continue; |
| | |||||||||||||||
12 | try |
| 9 | try | ||||||||||||||
13 | log("Copying " + fromFile + " to " + toFile, verbosity); |
| 10 | log("Copying " + fromResource + " to " + toFile, verbosity); | ||||||||||||||
14 | FilterSetCollection executionFilters = new FilterSetCollection(); | 11 | FilterSetCollection executionFilters = new FilterSetCollection(); | |||||||||||||||
15 | if (filtering) | 12 | if (filtering) | |||||||||||||||
16 | executionFilters.addFilterSet(getProject().getGlobalFilterSet()); | 13 | executionFilters.addFilterSet(getProject().getGlobalFilterSet()); | |||||||||||||||
17 | for (Enumeration filterEnum = filterSets.elements(); filterEnum.hasMoreElements(); ) | 14 | for (Enumeration filterEnum = filterSets.elements(); filterEnum.hasMoreElements(); ) | |||||||||||||||
18 | executionFilters.addFilterSet((FilterSet)filterEnum.nextElement()); | 15 | executionFilters.addFilterSet((FilterSet)filterEnum.nextElement()); | |||||||||||||||
|
| 16 | ResourceUtils.copyResource(fromResource, new FileResource(destDir, toFile), executionFilters, filterChains, forceOverwrite, preserveLastModified, inputEncoding, outputEncoding, getProject()); | |||||||||||||||
19 | fileUtils.copyFile(fromFile, toFile, executionFilters, filterChains, forceOverwrite, preserveLastModified, inputEncoding, outputEncoding, getProject()); |
| |
Row | Violation |
---|---|
1 | Unmatched statement if(fromFile.equals(toFile)) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched continue; |
3 | Type java.lang.String of variable fromFile does not match with type org.apache.tools.ant.types.Resource of variable fromResource |
4 | Type java.lang.String of variable fromFile does not match with type org.apache.tools.ant.types.Resource of variable fromResource |
5 | Unmatched statement ResourceUtils.copyResource(fromResource,new FileResource(destDir,toFile),executionFilters,filterChains,forceOverwrite,preserveLastModified,inputEncoding,outputEncoding,getProject()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
6 | Unmatched statement ResourceUtils.copyResource(fromResource,new FileResource(destDir,toFile),executionFilters,filterChains,forceOverwrite,preserveLastModified,inputEncoding,outputEncoding,getProject()); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
7 | Unmatched statement fileUtils.copyFile(fromFile,toFile,executionFilters,filterChains,forceOverwrite,preserveLastModified,inputEncoding,outputEncoding,getProject()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
8 | Unmatched statement fileUtils.copyFile(fromFile,toFile,executionFilters,filterChains,forceOverwrite,preserveLastModified,inputEncoding,outputEncoding,getProject()); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
9 | Clone fragment #1 returns variables toFile, executionFilters , while Clone fragment #2 returns variables toFile, executionFilters |