FormatterElement fe = feArray[i]; if (fe.shouldUse(this)) { formatterArg.append(Constants.FORMATTER); formatterArg.append(fe.getClassname()); File outFile = getOutput(fe, test); if (outFile != null) { formatterArg.append(","); formatterArg.append(outFile); } cmd.createArgument().setValue(formatterArg.toString()); formatterArg = new StringBuffer(); }
mapper = (FileNameMapper) (mIter.next()); if (mapper != null) { inputs.clear(); inputs.addAll(results); results.clear(); for (Iterator it = inputs.iterator(); it.hasNext();) { String[] mapped = mapper.mapFileName((String) (it.next())); if (mapped != null) { results.addAll(Arrays.asList(mapped)); } } }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/util/ChainedMapper.java
Method name: TestResultHolder executeAsForked(JUnitTest, ExecuteWatchdog, File) Method name: String[] mapFileName(String)
Number of AST nodes: 10 Number of AST nodes: 9
1
FormatterElement fe = feArray[i];
2
            if (fe.shouldUse(this)) {
3
                formatterArg.append(Constants.FORMATTER);
4
                formatterArg.append(fe.getClassname());
5
                File outFile = getOutput(fe, test
1
mapper = (FileNameMapper) (mIter.next());
2
            if (mapper != null) {
3
                inputs.clear();
4
                inputs.addAll(results);
6
);
5
                results.clear();
7
                if (outFile != null) {
6
                
8
                    formatterArg.append(","
7
for (Iterator it = inputs.iterator(); it.hasNext();) {
9
);
8
                    String[] mapped = mapper.mapFileName((String) (it.next()));
10
                    formatterArg.append(outFile);
9
                    
11
      
10
if (mapped != null) {
12
          }
11
          
13
                cmd.createArgument().setValue(formatterArg.toString());
12
              
14
                formatterArg = new StringBuffer();
13
results.addAll(Arrays.asList(mapped));
14
                    }
15
                }
15
            }
16
            }
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 comparisons11
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements1
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)0.9
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                                            
    12
    String[] mapped = mapper.mapFileName((String)(it.next()));
    Preondition Violations
    Unmatched statement String[] mapped=mapper.mapFileName((String)(it.next())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12
    String[] mapped = mapper.mapFileName((String)(it.next()));
    36
    formatterArg.append(Constants.FORMATTER);
                                                                                              
    37
    formatterArg.append(fe.getClassname());
                                                                                          
    38
    File outFile = getOutput(fe, test);
    38
    File outFile = getOutput(fe, test);
    Preondition Violations
    Unmatched statement File outFile=getOutput(fe,test); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                            
    39
    if (outFile != null)
    39
    if (outFile != null)
    13
    if (mapped != null)
    Differences
    Expression1Expression2Difference
    outFilemappedVARIABLE_NAME_MISMATCH
    java.io.Filejava.lang.String[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.io.File of variable outFile does not match with type java.lang.String[] of variable mapped
    • Make classes java.io.File and java.lang.String[] extend a common superclass
    13
    if (mapped != null)
                                                                                        
    14
    results.addAll(Arrays.asList(mapped));
    40
    formatterArg.append(",");
                                                              
    41
    formatterArg.append(outFile);
                                                                      
    Precondition Violations (3)
    Row Violation
    1Unmatched statement String[] mapped=mapper.mapFileName((String)(it.next())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement File outFile=getOutput(fe,test); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Type java.io.File of variable outFile does not match with type java.lang.String[] of variable mapped