for (int i = 0; i < children.length; ++i) { File file = children[i]; // Test here again to avoid method call for non-directories! if (file.isDirectory()) { removedCount += removeEmptyDirectories(file, true); } }
File resource = new File(file, resourceName); if (resource.exists()) { return new FileInputStream(resource); }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/Sync.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/AntClassLoader.java
Method name: int removeEmptyDirectories(File, boolean) Method name: InputStream getResourceStream(File, String)
Number of AST nodes: 4 Number of AST nodes: 3
1
for (int i = 0; i < children.length; ++i) {
2
                File file = children[i];
1
File resource = new File(file
3
                // Test here again to avoid method call for non-directories!
2
, resourceName);
4
                if (file.isDirectory()) {
3
                if (resource.exists()) {
5
                    removedCount += removeEmptyDirectories(file, true);
4
                    return new FileInputStream(resource);
6
                }
5
                }
7
            }
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)0.1
Clones locationClones are in different classes
Number of node comparisons6
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    5
    File file = children[i];
    5
    File file = children[i];
    5
    File resource = new File(file, resourceName);
    Differences
    Expression1Expression2Difference
    fileresourceVARIABLE_NAME_MISMATCH
    children[i]new File(file,resourceName)TYPE_COMPATIBLE_REPLACEMENT
    5
    File resource = new File(file, resourceName);
    6
    if (file.isDirectory())
    6
    if (file.isDirectory())
    6
    if (resource.exists())
    Differences
    Expression1Expression2Difference
    isDirectoryexistsMETHOD_INVOCATION_NAME_MISMATCH
    fileresourceVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression file.isDirectory() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression resource.exists() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    if (resource.exists())
                                                                                    
    7
    return new FileInputStream(resource);
    7
    removedCount += removeEmptyDirectories(file, true);
    7
    removedCount += removeEmptyDirectories(file, true);
    Preondition Violations
    Unmatched statement removedCount+=removeEmptyDirectories(file,true); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                          
    Precondition Violations (3)
    Row Violation
    1Expression file.isDirectory() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression resource.exists() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Unmatched statement removedCount+=removeEmptyDirectories(file,true); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted