List nestedElementList = (List) nestedElementMap.get(name); if (nestedElementList == null) { nestedElementList = new ArrayList(); nestedElementMap.put(name, nestedElementList); } Object element = getScript().createNestedElement(name); nestedElementList.add(element); return element;
ForkedTestConfiguration c = new ForkedTestConfiguration(test); List l = (List) testConfigurations.get(c); if (l == null) { l = new ArrayList(); testConfigurations.put(c, l); } l.add(test);
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/script/ScriptDefBase.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
Method name: Object createDynamicElement(String) Method name: Collection executeOrQueue(Enumeration, boolean)
Number of AST nodes: 7 Number of AST nodes: 6
1
List nestedElement
1
ForkedTestConfiguration c =
2
                        new ForkedTestConfiguration(test);
2
List = (List) nestedElementMap.get(name);
3
                    List l = (List) testConfigurations.get(c);
3
        if (nestedElementList == null) {
4
                    if (l == null) {
4
            nestedElementList = new ArrayList();
5
                        l = new ArrayList();
5
            nestedElementMap.put(name, nestedElementList);
6
                        testConfigurations.put(c, l);
6
        }
7
        
7
        Object element = getScript().createNestedElement(name);
8
        
8
        nestedElementList.add(element);
9
        return element
9
    }
10
;
10
                    l.add(test);
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 having the same super class
Number of node comparisons17
  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.8
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                                                  
    7
    ForkedTestConfiguration c = new ForkedTestConfiguration(test);
    Preondition Violations
    Unmatched statement ForkedTestConfiguration c=new ForkedTestConfiguration(test); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    ForkedTestConfiguration c = new ForkedTestConfiguration(test);
    1
    List nestedElementList = (List)nestedElementMap.get(name);
    1
    List nestedElementList = (List)nestedElementMap.get(name);
    8
    List l = (List)testConfigurations.get(c);
    Differences
    Expression1Expression2Difference
    nestedElementListlVARIABLE_NAME_MISMATCH
    namecVARIABLE_NAME_MISMATCH
    java.lang.Stringorg.apache.tools.ant.taskdefs.optional.junit.JUnitTask.ForkedTestConfigurationVARIABLE_TYPE_MISMATCH
    nestedElementMaptestConfigurationsVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression l cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type java.lang.String of variable name does not match with type org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.ForkedTestConfiguration of variable c
    • Make classes java.lang.String and org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.ForkedTestConfiguration extend a common superclass
    8
    List l = (List)testConfigurations.get(c);
    2
    if (nestedElementList == null)
    2
    if (nestedElementList == null)
    9
    if (l == null)
    Differences
    Expression1Expression2Difference
    nestedElementListlVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression nestedElementList cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression l cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9
    if (l == null)
    3
    nestedElementList = new ArrayList();
    3
    nestedElementList = new ArrayList();
    10
    l = new ArrayList();
    Differences
    Expression1Expression2Difference
    nestedElementListlVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression nestedElementList cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression l cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10
    l = new ArrayList();
    4
    nestedElementMap.put(name, nestedElementList);
    4
    nestedElementMap.put(name, nestedElementList);
    11
    testConfigurations.put(c, l);
    Differences
    Expression1Expression2Difference
    namecVARIABLE_NAME_MISMATCH
    java.lang.Stringorg.apache.tools.ant.taskdefs.optional.junit.JUnitTask.ForkedTestConfigurationVARIABLE_TYPE_MISMATCH
    nestedElementMaptestConfigurationsVARIABLE_NAME_MISMATCH
    Preondition Violations
    Type java.lang.String of variable name does not match with type org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.ForkedTestConfiguration of variable c
    • Make classes java.lang.String and org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.ForkedTestConfiguration extend a common superclass
    11
    testConfigurations.put(c, l);
    5
    Object element = getScript().createNestedElement(name);
                                                                                                                    
    6
    nestedElementList.add(element);
    6
    nestedElementList.add(element);
    12
    l.add(test);
    Differences
    Expression1Expression2Difference
    elementtestVARIABLE_NAME_MISMATCH
    java.lang.Objectorg.apache.tools.ant.taskdefs.optional.junit.JUnitTestVARIABLE_TYPE_MISMATCH
    nestedElementListlVARIABLE_NAME_MISMATCH
    Preondition Violations
    Type java.lang.Object of variable element does not match with type org.apache.tools.ant.taskdefs.optional.junit.JUnitTest of variable test
    • Make classes java.lang.Object and org.apache.tools.ant.taskdefs.optional.junit.JUnitTest extend a common superclass
    Expression nestedElementList cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression l cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12
    l.add(test);
    7
    return element;
    7
    return element;
    Preondition Violations
    Unmatched return element;
                                        
    Precondition Violations (12)
    Row Violation
    1Unmatched statement ForkedTestConfiguration c=new ForkedTestConfiguration(test); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Expression l cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Type java.lang.String of variable name does not match with type org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.ForkedTestConfiguration of variable c
    4Expression nestedElementList cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression l cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression nestedElementList cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression l cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Type java.lang.String of variable name does not match with type org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.ForkedTestConfiguration of variable c
    9Type java.lang.Object of variable element does not match with type org.apache.tools.ant.taskdefs.optional.junit.JUnitTest of variable test
    10Expression nestedElementList cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression l cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Unmatched return element;