Attribute attribute = (Attribute) i.next(); if (attribute.name == null) { throw new BuildException("scriptdef <attribute> elements " + "must specify an attribute name"); } if (attributeSet.contains(attribute.name)) { throw new BuildException("scriptdef <" + name + "> declares " + "the " + attribute.name + " attribute more than once"); }
NestedElement nestedElement = (NestedElement) i.next(); if (nestedElement.name == null) { throw new BuildException("scriptdef <element> elements " + "must specify an element name"); } if (nestedElementMap.containsKey(nestedElement.name)) { throw new BuildException("scriptdef <" + name + "> declares " + "the " + nestedElement.name + " nested element more " + "than once"); }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java
Method name: void execute() Method name: void execute()
Number of AST nodes: 5 Number of AST nodes: 5
1
Attribute attribute = (Attribute) i.next();
1
NestedElement nestedElement = (NestedElement) i.next();
2
            if (attribute.name == null) {
2
            if (nestedElement.name == null) {
3
                throw new BuildException("scriptdef <attribute> elements "
3
                throw new BuildException("scriptdef <element> elements "
4
                    + "must specify an attribute name");
4
                    + "must specify an element name");
5
            }
5
            }
6
            if (attributeSet.contains(attribute.name)) {
6
            if (nestedElementMap.containsKey(nestedElement.name)) {
7
                throw new BuildException("scriptdef <" + name + "> declares "
7
                throw new BuildException("scriptdef <" + name + "> declares "
8
                    + "the " + attribute.name + " attribute more 
8
                    + "the " + nestedElement.name + " nested element more "
9
than once");
9
                    + "than once");
10
            }
10
            }
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.4
Clones locationClones are in the same method
Number of node comparisons9
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    10
    Attribute attribute = (Attribute)i.next();
    10
    Attribute attribute = (Attribute)i.next();
    Preondition Violations
    Unmatched statement Attribute attribute=(Attribute)i.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                            
                                                                                                                    
    18
    NestedElement nestedElement = (NestedElement)i.next();
    Preondition Violations
    Unmatched statement NestedElement nestedElement=(NestedElement)i.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    18
    NestedElement nestedElement = (NestedElement)i.next();
    11
    if (attribute.name == null)
    11
    if (attribute.name == null)
    19
    if (nestedElement.name == null)
    Differences
    Expression1Expression2Difference
    attributenestedElementVARIABLE_NAME_MISMATCH
    org.apache.tools.ant.taskdefs.optional.script.ScriptDef.Attributeorg.apache.tools.ant.taskdefs.optional.script.ScriptDef.NestedElementVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.apache.tools.ant.taskdefs.optional.script.ScriptDef.Attribute of variable attribute does not match with type org.apache.tools.ant.taskdefs.optional.script.ScriptDef.NestedElement of variable nestedElement
    • Make classes org.apache.tools.ant.taskdefs.optional.script.ScriptDef.Attribute and org.apache.tools.ant.taskdefs.optional.script.ScriptDef.NestedElement extend a common superclass
    19
    if (nestedElement.name == null)
    12
    throw new BuildException("scriptdef <attribute> elements " + "must specify an attribute name");
    12
    throw new BuildException("scriptdef <attribute> elements " + "must specify an attribute name");
    20
    throw new BuildException("scriptdef <element> elements " + "must specify an element name");
    Differences
    Expression1Expression2Difference
    "scriptdef elements ""scriptdef elements "LITERAL_VALUE_MISMATCH
    "must specify an attribute name""must specify an element name"LITERAL_VALUE_MISMATCH
    20
    throw new BuildException("scriptdef <element> elements " + "must specify an element name");
    Precondition Violations (3)
    Row Violation
    1Unmatched statement Attribute attribute=(Attribute)i.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement NestedElement nestedElement=(NestedElement)i.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Type org.apache.tools.ant.taskdefs.optional.script.ScriptDef.Attribute of variable attribute does not match with type org.apache.tools.ant.taskdefs.optional.script.ScriptDef.NestedElement of variable nestedElement