if (path != null) { Path p = new Path(getProject(), path); String[] pElements = p.list(); for (int i = 0; i < pElements.length; i++) { File f = new File(pElements[i], "rpmbuild" + (Os.isFamily("dos") ? ".exe" : "")); if (f.canRead()) { return f.getAbsolutePath(); } } }
if (p != null) { String[] dirs = p.list(); for (int i = 0; i < dirs.length; i++) { executableFile = FILE_UTILS.resolveFile(new File(dirs[i]), exec); if (executableFile.exists()) { return executableFile.getAbsolutePath(); } } }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/Rpm.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/ExecTask.java
Method name: String guessRpmBuildCommand() Method name: String resolveExecutable(String, boolean)
Number of AST nodes: 7 Number of AST nodes: 6
1
if (path != null) {
1
if (p != null) {
2
            Path p = new Path(getProject(), path);
2
    
3
            String[] pElements = p.list();
3
            String[] dirs = p.list();
4
            for (int i = 0; i < pElements.length; i++) {
4
                for (int i = 0; i < dirs.length; i++) {
5
                File f = new File(pElements[i],
5
                
6
                                  "rpmbuild"
7
                                  + (Os.isFamily("dos") ? ".exe" : ""));
8
                if (f.canRead
6
    executableFile
7
                        = FILE_UTILS.resolveFile(new File(dirs[i]), exec);
9
()) {
8
                    if (executableFile.exists()) {
10
                    return f.getAbsolutePath();
9
                        return executableFile.getAbsolutePath();
11
                }
10
                
11
    }
12
            }
12
                }
13
        }
13
            }
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.3
Clones locationClones are in different classes having the same super class
Number of node comparisons16
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.2
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    8
    if (path != null)
    8
    if (path != null)
    26
    if (p != null)
    Differences
    Expression1Expression2Difference
    pathpVARIABLE_NAME_MISMATCH
    java.lang.Stringorg.apache.tools.ant.types.PathVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.String of variable path does not match with type org.apache.tools.ant.types.Path of variable p
    • Make classes java.lang.String and org.apache.tools.ant.types.Path extend a common superclass
    26
    if (p != null)
    9
    Path p = new Path(getProject(), path);
                                                                                
    10
    String[] pElements = p.list();
    10
    String[] pElements = p.list();
    27
    String[] dirs = p.list();
    Differences
    Expression1Expression2Difference
    pElementsdirsVARIABLE_NAME_MISMATCH
    27
    String[] dirs = p.list();
    11
    for (int i = 0; i < pElements.length; i++)
    11
    for (int i = 0; i < pElements.length; i++)
    28
    for (int i = 0; i < dirs.length; i++)
    Differences
    Expression1Expression2Difference
    pElementsdirsVARIABLE_NAME_MISMATCH
    28
    for (int i = 0; i < dirs.length; i++)
    12
    File f = new File(pElements[i], "rpmbuild" + (Os.isFamily("dos") ? ".exe" : ""));
    12
    File f = new File(pElements[i], "rpmbuild" + (Os.isFamily("dos") ? ".exe" : ""));
    Preondition Violations
    Unmatched statement File f=new File(pElements[i],"rpmbuild" + (Os.isFamily("dos") ? ".exe" : "")); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                                        
                                                                                                                                        
    29
    executableFile = FILE_UTILS.resolveFile(new File(dirs[i]), exec);
    Preondition Violations
    Unmatched statement executableFile=FILE_UTILS.resolveFile(new File(dirs[i]),exec); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    29
    executableFile = FILE_UTILS.resolveFile(new File(dirs[i]), exec);
    13
    if (f.canRead())
    13
    if (f.canRead())
    30
    if (executableFile.exists())
    Differences
    Expression1Expression2Difference
    canReadexistsMETHOD_INVOCATION_NAME_MISMATCH
    fexecutableFileVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression f.canRead() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression executableFile.exists() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    30
    if (executableFile.exists())
    14
    return f.getAbsolutePath();
    14
    return f.getAbsolutePath();
    31
    return executableFile.getAbsolutePath();
    Differences
    Expression1Expression2Difference
    fexecutableFileVARIABLE_NAME_MISMATCH
    31
    return executableFile.getAbsolutePath();
    Precondition Violations (6)
    Row Violation
    1Type java.lang.String of variable path does not match with type org.apache.tools.ant.types.Path of variable p
    2Unmatched statement File f=new File(pElements[i],"rpmbuild" + (Os.isFamily("dos") ? ".exe" : "")); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement executableFile=FILE_UTILS.resolveFile(new File(dirs[i]),exec); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Expression f.canRead() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression executableFile.exists() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Clone fragment #1 returns variables pElements, i , while Clone fragment #2 returns variables dirs, i