String attributeName = (String) e.nextElement(); Attribute attribute = section.getAttribute(attributeName); if (attributeName.equalsIgnoreCase(ATTRIBUTE_CLASSPATH)) { if (classpathAttribute == null) { classpathAttribute = new Attribute(); classpathAttribute.setName(ATTRIBUTE_CLASSPATH); } Enumeration cpe = attribute.getValues(); while (cpe.hasMoreElements()) { String value = (String) cpe.nextElement(); classpathAttribute.addValue(value); } } else { // the merge file always wins storeAttribute(attribute); }
while (iter.hasNext()) { FileResource r = (FileResource) iter.next(); File base = r.getBaseDir(); if (base == null) { base = Copy.NULL_FILE_PLACEHOLDER; } basedirs.add(base); Vector files = (Vector) basedirToFilesMap.get(base); if (files == null) { files = new Vector(); basedirToFilesMap.put(base, new Vector()); } files.add(r.getName()); }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/Manifest.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/Tar.java
Method name: void merge(Section) Method name: boolean check(ResourceCollection)
Number of AST nodes: 11 Number of AST nodes: 11
1
String attributeName = (String) e.nextElement();
2
                Attribute attribute = section.getAttribute(attributeName);
3
                if (attributeName.equalsIgnoreCase(ATTRIBUTE_CLASSPATH)) {
4
    
1
while (iter.hasNext()) {
2
                FileResource r = (FileResource) iter.next();
3
                File base = r.getBaseDir();
5
                if (classpathAttribute == null) {
4
                if (base == null) {
6
                        classpathAttribute = new Attribute();
5
                    
7
                        classpathAttribute.setName(ATTRIBUTE_CLASSPATH);
8
                    }
9
                    Enumeration cpe = attribute.getValues();
10
                    while (cpe.hasMoreElements()) {
11
                        String value = (String) cpe.nextElement();
12
                        classpathAttribute.addValue(value);
13
                    }
6
base = Copy.NULL_FILE_PLACEHOLDER;
7
                }
8
                basedirs.add(base);
9
                Vector files = (Vector) basedirToFilesMap.get(base);
10
                if (files == null) {
11
                    files = new Vector();
12
                    basedirToFilesMap.put(base, new Vector());
14
                } else {
13
                }
15
    
16
                // the merge file always wins
14
                
17
                    storeAttribute(attribute);
18
    
15
files.add(r.getName());
19
            }
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.2
Clones locationClones are in different classes
Number of node comparisons10
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements1
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)1.1
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                              
    12
    FileResource r = (FileResource)iter.next();
                                                              
    13
    File base = r.getBaseDir();
    Preondition Violations
    Unmatched statement File base=r.getBaseDir(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13
    File base = r.getBaseDir();
    9
    if (classpathAttribute == null)
    9
    if (classpathAttribute == null)
    14
    if (base == null)
    Differences
    Expression1Expression2Difference
    classpathAttributebaseVARIABLE_NAME_MISMATCH
    org.apache.tools.ant.taskdefs.Manifest.Attributejava.io.FileVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.apache.tools.ant.taskdefs.Manifest.Attribute of variable classpathAttribute does not match with type java.io.File of variable base
    • Make classes org.apache.tools.ant.taskdefs.Manifest.Attribute and java.io.File extend a common superclass
    14
    if (base == null)
    10
    classpathAttribute = new Attribute();
    10
    classpathAttribute = new Attribute();
    Preondition Violations
    Unmatched statement classpathAttribute=new Attribute(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                  
    11
    classpathAttribute.setName(ATTRIBUTE_CLASSPATH);
                                                                                                            
                                                                            
    15
    base = Copy.NULL_FILE_PLACEHOLDER;
    Preondition Violations
    Unmatched statement base=Copy.NULL_FILE_PLACEHOLDER; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15
    base = Copy.NULL_FILE_PLACEHOLDER;
    Precondition Violations (4)
    Row Violation
    1Unmatched statement File base=r.getBaseDir(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Type org.apache.tools.ant.taskdefs.Manifest.Attribute of variable classpathAttribute does not match with type java.io.File of variable base
    3Unmatched statement classpathAttribute=new Attribute(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement base=Copy.NULL_FILE_PLACEHOLDER; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted