if (project == null) { if (workingDir == null) { return exec(project, cmd, env); } throw new IOException("Cannot locate antRun script: " + "No project provided"); } // Locate the auxiliary script String antHome = project.getProperty(MagicNames.ANT_HOME); if (antHome == null) { throw new IOException("Cannot locate antRun script: " + "Property '" + MagicNames.ANT_HOME + "' not found"); } String antRun = FILE_UTILS.resolveFile(project.getBaseDir(), antHome + File.separator + myScript).toString(); // Build the command File commandDir = workingDir; if (workingDir == null && project != null) { commandDir = project.getBaseDir(); } String[] newcmd = new String[cmd.length + 2]; newcmd[0] = antRun; newcmd[1] = commandDir.getAbsolutePath(); System.arraycopy(cmd, 0, newcmd, 2, cmd.length); return exec(project, newcmd, env);
if (project == null) { if (workingDir == null) { return exec(project, cmd, env); } throw new IOException("Cannot locate antRun script: " + "No project provided"); } // Locate the auxiliary script String antHome = project.getProperty(MagicNames.ANT_HOME); if (antHome == null) { throw new IOException("Cannot locate antRun script: " + "Property '" + MagicNames.ANT_HOME + "' not found"); } String antRun = FILE_UTILS.resolveFile(project.getBaseDir(), antHome + File.separator + myScript).toString(); // Build the command File commandDir = workingDir; if (workingDir == null && project != null) { commandDir = project.getBaseDir(); } String[] newcmd = new String[cmd.length + 3]; newcmd[0] = "perl"; newcmd[1] = antRun; newcmd[2] = commandDir.getAbsolutePath(); System.arraycopy(cmd, 0, newcmd, 3, cmd.length); return exec(project, newcmd, env);
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/Execute.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/Execute.java
Method name: Process exec(Project, String[], String[], File) Method name: Process exec(Project, String[], String[], File)
Number of AST nodes: 16 Number of AST nodes: 17
1
if (project == null) {
1
if (project == null) {
2
                if (workingDir == null) {
2
                if (workingDir == null) {
3
                    return exec(project, cmd, env);
3
                    return exec(project, cmd, env);
4
                }
4
                }
5
                throw new IOException("Cannot locate antRun script: "
5
                throw new IOException("Cannot locate antRun script: "
6
                    + "No project provided");
6
                    + "No project provided");
7
            }
7
            }
8
            // Locate the auxiliary script
8
            // Locate the auxiliary script
9
            String antHome = project.getProperty(MagicNames.ANT_HOME);
9
            String antHome = project.getProperty(MagicNames.ANT_HOME);
10
            if (antHome == null) {
10
            if (antHome == null) {
11
                throw new IOException("Cannot locate antRun script: "
11
                throw new IOException("Cannot locate antRun script: "
12
                    + "Property '" + MagicNames.ANT_HOME + "' not found");
12
                    + "Property '" + MagicNames.ANT_HOME + "' not found");
13
            }
13
            }
14
            String antRun =
14
            String antRun =
15
                FILE_UTILS.resolveFile(project.getBaseDir(),
15
                FILE_UTILS.resolveFile(project.getBaseDir(),
16
                        antHome + File.separator + myScript).toString();
16
                        antHome + File.separator + myScript).toString();
17
            // Build the command
17
            // Build the command
18
            File commandDir = workingDir;
18
            File commandDir = workingDir;
19
            if (workingDir == null && project != null) {
19
            if (workingDir == null && project != null) {
20
                commandDir = project.getBaseDir();
20
                commandDir = project.getBaseDir();
21
            }
21
            }
22
            String[] newcmd = new String[cmd.length + 2];
22
            String[] newcmd = new String[cmd.length + 3];
23
            newcmd[0] =
23
            newcmd[0] = "perl";
24
 antRun;
24
            newcmd[1] = antRun;
25
            newcmd[1] = commandDir.getAbsolutePath();
25
            newcmd[2] = commandDir.getAbsolutePath();
26
            System.arraycopy(cmd, 0, newcmd, 2, cmd.length);
26
            System.arraycopy(cmd, 0, newcmd, 3, cmd.length);
27
            return exec(project, newcmd, env);
27
            return exec(project, newcmd, env);
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.8
Clones locationClones are in the same java file
Number of node comparisons93
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements16
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)6.4
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    if (project == null)
    1
    if (project == null)
    2
    if (workingDir == null)
    2
    if (workingDir == null)
    3
    return exec(project, cmd, env);
    3
    return exec(project, cmd, env);
    4
    throw new IOException("Cannot locate antRun script: " + "No project provided");
    4
    throw new IOException("Cannot locate antRun script: " + "No project provided");
    5
    String antHome = project.getProperty(MagicNames.ANT_HOME);
    5
    String antHome = project.getProperty(MagicNames.ANT_HOME);
    6
    if (antHome == null)
    6
    if (antHome == null)
    7
    throw new IOException("Cannot locate antRun script: " + "Property '" + MagicNames.ANT_HOME + "' not found");
    7
    throw new IOException("Cannot locate antRun script: " + "Property '" + MagicNames.ANT_HOME + "' not found");
    8
    String antRun = FILE_UTILS.resolveFile(project.getBaseDir(), antHome + File.separator + myScript).toString();
    8
    String antRun = FILE_UTILS.resolveFile(project.getBaseDir(), antHome + File.separator + myScript).toString();
    9
    File commandDir = workingDir;
    9
    File commandDir = workingDir;
    10
    if (workingDir == null && project != null)
    10
    if (workingDir == null && project != null)
    11
    commandDir = project.getBaseDir();
    11
    commandDir = project.getBaseDir();
    12
    String[] newcmd = new String[cmd.length + 2];
    12
    String[] newcmd = new String[cmd.length + 2];
    12
    String[] newcmd = new String[cmd.length + 3];
    Differences
    Expression1Expression2Difference
    23LITERAL_VALUE_MISMATCH
    12
    String[] newcmd = new String[cmd.length + 3];
                                              
    13
    newcmd[0] = "perl";
    Preondition Violations
    Unmatched statement newcmd[0]="perl"; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13
    newcmd[0] = "perl";
    13
    newcmd[0] = antRun;
    13
    newcmd[0] = antRun;
    14
    newcmd[1] = antRun;
    Differences
    Expression1Expression2Difference
    01LITERAL_VALUE_MISMATCH
    14
    newcmd[1] = antRun;
    14
    newcmd[1] = commandDir.getAbsolutePath();
    14
    newcmd[1] = commandDir.getAbsolutePath();
    15
    newcmd[2] = commandDir.getAbsolutePath();
    Differences
    Expression1Expression2Difference
    12LITERAL_VALUE_MISMATCH
    15
    newcmd[2] = commandDir.getAbsolutePath();
    15
    System.arraycopy(cmd, 0, newcmd, 2, cmd.length);
    15
    System.arraycopy(cmd, 0, newcmd, 2, cmd.length);
    16
    System.arraycopy(cmd, 0, newcmd, 3, cmd.length);
    Differences
    Expression1Expression2Difference
    23LITERAL_VALUE_MISMATCH
    16
    System.arraycopy(cmd, 0, newcmd, 3, cmd.length);
    16
    return exec(project, newcmd, env);
    17
    return exec(project, newcmd, env);
    Precondition Violations (2)
    Row Violation
    1Unmatched statement newcmd[0]="perl"; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Clone fragment #1 returns variables , while Clone fragment #2 returns variables newcmd