for (int j = 0; j < f.length; j++) { String pathname = f[j]; if (pathname.endsWith(".xml")) { File file = new File(ds.getBasedir(), pathname); file = getProject().resolveFile(file.getPath()); v.addElement(file); } }
for (int i = 0; i < parameters.length; i++) { String paramname = parameters[i].getName(); if (TYPE_KEY.equalsIgnoreCase(paramname)) { FileType t = new FileType(); t.setValue(parameters[i].getValue()); setType(t); } else { setError("Invalid parameter " + paramname); } }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/types/selectors/TypeSelector.java
Method name: File[] getFiles() Method name: void setParameters(Parameter[])
Number of AST nodes: 6 Number of AST nodes: 7
1
for (int j = 0; j < f.length; j++) {
1
for (int i = 0; i < parameters.length; i++) {
2
                String pathname = f[j];
2
                String paramname = 
3
                if (pathname.endsWith(".xml"
3
parameters[i].getName();
4
)) {
4
                if (TYPE_KEY.equalsIgnoreCase(paramname)) {
5
                    File file = new File(ds.getBasedir(), pathname);
5
                    FileType t = new File
6
                    file = getProject().resolveFile(file.getPath());
7
                    v.addElement(fil
6
Type();
7
                    t.setValue(parameters[i].getValue());
8
                    setType(t);
9
                } else {
8
e);
10
                    setError("Invalid parameter " + paramname);
9
                }
11
                }
10
            }
12
            }
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 having the same super class
Number of node comparisons26
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)1.7
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    8
    for (int j = 0; j < f.length; j++)
    8
    for (int j = 0; j < f.length; j++)
    3
    for (int i = 0; i < parameters.length; i++)
    Differences
    Expression1Expression2Difference
    jiVARIABLE_NAME_MISMATCH
    jiVARIABLE_NAME_MISMATCH
    fparametersVARIABLE_NAME_MISMATCH
    java.lang.String[]org.apache.tools.ant.types.Parameter[]VARIABLE_TYPE_MISMATCH
    jiVARIABLE_NAME_MISMATCH
    Preondition Violations
    Type java.lang.String[] of variable f does not match with type org.apache.tools.ant.types.Parameter[] of variable parameters
    • Make classes java.lang.String[] and org.apache.tools.ant.types.Parameter[] extend a common superclass
    3
    for (int i = 0; i < parameters.length; i++)
    9
    String pathname = f[j];
    9
    String pathname = f[j];
    4
    String paramname = parameters[i].getName();
    Differences
    Expression1Expression2Difference
    pathnameparamnameVARIABLE_NAME_MISMATCH
    f[j]parameters[i].getName()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression pathname cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression paramname cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression f[j] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression parameters[i].getName() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4
    String paramname = parameters[i].getName();
    10
    if (pathname.endsWith(".xml"))
    10
    if (pathname.endsWith(".xml"))
    5
    if (TYPE_KEY.equalsIgnoreCase(paramname))
    Differences
    Expression1Expression2Difference
    endsWithequalsIgnoreCaseMETHOD_INVOCATION_NAME_MISMATCH
    ".xml"paramnameTYPE_COMPATIBLE_REPLACEMENT
    pathnameTYPE_KEYVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression pathname.endsWith(".xml") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression TYPE_KEY.equalsIgnoreCase(paramname) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression paramname cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression pathname cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    if (TYPE_KEY.equalsIgnoreCase(paramname))
                                                              
    6
    FileType t = new FileType();
    Preondition Violations
    Unmatched statement FileType t=new FileType(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    FileType t = new FileType();
                                                                                    
    7
    t.setValue(parameters[i].getValue());
    Preondition Violations
    Unmatched statement t.setValue(parameters[i].getValue()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    t.setValue(parameters[i].getValue());
                                
    8
    setType(t);
    Preondition Violations
    Unmatched statement setType(t); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8
    setType(t);
            
    else
                                                                                                
    9
    setError("Invalid parameter " + paramname);
    Preondition Violations
    Unmatched statement setError("Invalid parameter " + paramname); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9
    setError("Invalid parameter " + paramname);
    11
    File file = new File(ds.getBasedir(), pathname);
    11
    File file = new File(ds.getBasedir(), pathname);
    Preondition Violations
    Unmatched statement File file=new File(ds.getBasedir(),pathname); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                      
    12
    file = getProject().resolveFile(file.getPath());
                                                                                                        
    13
    v.addElement(file);
    13
    v.addElement(file);
    Preondition Violations
    Unmatched statement v.addElement(file); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                  
    Precondition Violations (16)
    Row Violation
    1Type java.lang.String[] of variable f does not match with type org.apache.tools.ant.types.Parameter[] of variable parameters
    2Expression pathname cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression paramname cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression f[j] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression parameters[i].getName() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression pathname.endsWith(".xml") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression TYPE_KEY.equalsIgnoreCase(paramname) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression paramname cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression pathname cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Unmatched statement FileType t=new FileType(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched statement t.setValue(parameters[i].getValue()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Unmatched statement setType(t); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Unmatched statement setError("Invalid parameter " + paramname); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14Unmatched statement File file=new File(ds.getBasedir(),pathname); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Unmatched statement v.addElement(file); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16Clone fragment #1 returns variables pathname , while Clone fragment #2 returns variables i, paramname