String toFile = toFiles[i]; if (fromFile.equals(toFile)) { log("Skipping self-copy of " + fromFile, verbosity); continue; } try { log("Copying " + fromFile + " to " + toFile, verbosity); FilterSetCollection executionFilters = new FilterSetCollection(); if (filtering) { executionFilters .addFilterSet(getProject().getGlobalFilterSet()); } for (Enumeration filterEnum = filterSets.elements(); filterEnum.hasMoreElements();) { executionFilters .addFilterSet((FilterSet) filterEnum.nextElement()); } fileUtils.copyFile(fromFile, toFile, executionFilters, filterChains, forceOverwrite, preserveLastModified, inputEncoding, outputEncoding, getProject()); } catch (IOException ioe) { String msg = "Failed to copy " + fromFile + " to " + toFile + " due to " + getDueTo(ioe); File targetFile = new File(toFile); if (targetFile.exists() && !targetFile.delete()) { msg += " and I couldn't delete the corrupt " + toFile; } if (failonerror) { throw new BuildException(msg, ioe, getLocation()); } log(msg, Project.MSG_ERR); }
for (int i = 0; i < toFiles.length; i++) { String toFile = toFiles[i]; try { log("Copying " + fromResource + " to " + toFile, verbosity); FilterSetCollection executionFilters = new FilterSetCollection(); if (filtering) { executionFilters .addFilterSet(getProject().getGlobalFilterSet()); } for (Enumeration filterEnum = filterSets.elements(); filterEnum.hasMoreElements();) { executionFilters .addFilterSet((FilterSet) filterEnum.nextElement()); } ResourceUtils.copyResource(fromResource, new FileResource(destDir, toFile), executionFilters, filterChains, forceOverwrite, preserveLastModified, inputEncoding, outputEncoding, getProject()); } catch (IOException ioe) { String msg = "Failed to copy " + fromResource + " to " + toFile + " due to " + getDueTo(ioe); File targetFile = new File(toFile); if (targetFile.exists() && !targetFile.delete()) { msg += " and I couldn't delete the corrupt " + toFile; } if (failonerror) { throw new BuildException(msg, ioe, getLocation()); } log(msg, Project.MSG_ERR); } }
Clone fragments detected by clone detection tool
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
                }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)1.8
Clones locationClones are declared in the same class
Number of node comparisons34
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment4
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)8.9
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    8
    String toFile = toFiles[i];
    8
    String toFile = toFiles[i];
    9
    if (fromFile.equals(toFile))
    9
    if (fromFile.equals(toFile))
    Preondition Violations
    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
                                                                
    10
    log("Skipping self-copy of " + fromFile, verbosity);
                                                                                                                  
    11
    continue;
    11
    continue;
    Preondition Violations
    Unmatched continue;
                              
    12
    try
    12
    try
    9
    try
    Differences
    Expression1Expression2Difference
    fromFilefromResourceVARIABLE_NAME_MISMATCH
    java.lang.Stringorg.apache.tools.ant.types.ResourceVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.String of variable fromFile does not match with type org.apache.tools.ant.types.Resource of variable fromResource
    • Make classes java.lang.String and org.apache.tools.ant.types.Resource extend a common superclass
    9
    try
    13
    log("Copying " + fromFile + " to " + toFile, verbosity);
    13
    log("Copying " + fromFile + " to " + toFile, verbosity);
    10
    log("Copying " + fromResource + " to " + toFile, verbosity);
    Differences
    Expression1Expression2Difference
    fromFilefromResourceVARIABLE_NAME_MISMATCH
    java.lang.Stringorg.apache.tools.ant.types.ResourceVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.String of variable fromFile does not match with type org.apache.tools.ant.types.Resource of variable fromResource
    • Make classes java.lang.String and org.apache.tools.ant.types.Resource extend a common superclass
    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());
    Preondition Violations
    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
    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
    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());
    19
    fileUtils.copyFile(fromFile, toFile, executionFilters, filterChains, forceOverwrite, preserveLastModified, inputEncoding, outputEncoding, getProject());
    Preondition Violations
    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
    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
                                                                                                                                                                                                                                                                                                            
    Precondition Violations (9)
    Row Violation
    1Unmatched 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
    2Unmatched continue;
    3Type java.lang.String of variable fromFile does not match with type org.apache.tools.ant.types.Resource of variable fromResource
    4Type java.lang.String of variable fromFile does not match with type org.apache.tools.ant.types.Resource of variable fromResource
    5Unmatched 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
    6Unmatched 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
    7Unmatched 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
    8Unmatched 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
    9Clone fragment #1 returns variables toFile, executionFilters , while Clone fragment #2 returns variables toFile, executionFilters