for (int i = 0; i < entries.length; i++) { File f = new File(source, entries[i]); if (f.isFile()) { files.addElement(f); } }
for (int i = 0; i < ARCHIVE_LOCATIONS.length; i++) { File f = new File(home, ARCHIVE_LOCATIONS[i]); if (f.exists()) { return i; } }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/sound/SoundTask.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java
Method name: File getSource() Method name: int getArchiveLocationIndex(File)
Number of AST nodes: 4 Number of AST nodes: 4
1
for (int i = 0; i < entries.length; i++) {
1
for (int i = 0; i < ARCHIVE_LOCATIONS.length; i++) {
2
                        File f = new File(source, entries[i]);
2
            File f = new File(
3
            
3
home, ARCHIVE_LOCATIONS[i]);
4
            if (f.isFile()) {
4
            if (f.exists()) {
5
                            files.addElement(f);
5
                
6
                        }
7
            
6
return i;
7
            }
8
        }
8
        }
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.2
Clones locationClones are in different classes
Number of node comparisons8
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    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.8
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    6
    for (int i = 0; i < entries.length; i++)
    6
    for (int i = 0; i < entries.length; i++)
    3
    for (int i = 0; i < ARCHIVE_LOCATIONS.length; i++)
    Differences
    Expression1Expression2Difference
    entriesARCHIVE_LOCATIONSVARIABLE_NAME_MISMATCH
    3
    for (int i = 0; i < ARCHIVE_LOCATIONS.length; i++)
    7
    File f = new File(source, entries[i]);
    7
    File f = new File(source, entries[i]);
    4
    File f = new File(home, ARCHIVE_LOCATIONS[i]);
    Differences
    Expression1Expression2Difference
    sourcehomeVARIABLE_NAME_MISMATCH
    entriesARCHIVE_LOCATIONSVARIABLE_NAME_MISMATCH
    4
    File f = new File(home, ARCHIVE_LOCATIONS[i]);
    8
    if (f.isFile())
    8
    if (f.isFile())
    5
    if (f.exists())
    Differences
    Expression1Expression2Difference
    isFileexistsMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression f.isFile() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression f.exists() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    if (f.exists())
                            
    6
    return i;
    Preondition Violations
    Unmatched statement return i; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched return i;
    6
    return i;
    9
    files.addElement(f);
    9
    files.addElement(f);
    Preondition Violations
    Unmatched statement files.addElement(f); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                  
    Precondition Violations (6)
    Row Violation
    1Expression f.isFile() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression f.exists() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Unmatched statement return i; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched return i;
    5Unmatched statement files.addElement(f); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Clone fragment #1 returns variable f with type java.io.File , while Clone fragment #2 returns variable i with type int