while ((entry = ti.getNextEntry()) != null) { Resource r = new TarResource(src, entry); String name = entry.getName(); if (entry.isDirectory()) { name = trimSeparator(name); dirEntries.put(name, r); if (match(name)) { matchDirEntries.put(name, r); } } else { fileEntries.put(name, r); if (match(name)) { matchFileEntries.put(name, r); } } }
entry = (ZipEntry) e.nextElement(); Resource r = new ZipResource(srcFile, encoding, entry); String name = entry.getName(); if (entry.isDirectory()) { name = trimSeparator(name); dirEntries.put(name, r); if (match(name)) { matchDirEntries.put(name, r); } } else { fileEntries.put(name, r); if (match(name)) { matchFileEntries.put(name, r); } }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/types/TarScanner.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/types/ZipScanner.java
Method name: void fillMapsFromArchive(Resource, String, Map, Map, Map, Map) Method name: void fillMapsFromArchive(Resource, String, Map, Map, Map, Map)
Number of AST nodes: 11 Number of AST nodes: 11
1
while ((entry = ti.getNextEntry()) != null) {
1
entry = (ZipEntry) e.nextElement();
2
                Resource r = new TarResource(src, entry);
2
                Resource r = new ZipResource(srcFile, encoding, entry);
3
                String name = entry.getName();
3
                String name = entry.getName();
4
                if (entry.isDirectory()) {
4
                if (entry.isDirectory()) {
5
                    name = trimSeparator(name);
5
                    name = trimSeparator(name);
6
                    dirEntries.put(name, r);
6
                    dirEntries.put(name, r);
7
                    if (match(name)) {
7
                    if (match(name)) {
8
                        matchDirEntries.put(name, r);
8
                        matchDirEntries.put(name, r);
9
                    }
9
                    }
10
                } else {
10
                } else {
11
                    fileEntries.put(name, r);
11
                    fileEntries.put(name, r);
12
                    if (match(name)) {
12
                    if (match(name)) {
13
                        matchFileEntries.put(name, r);
13
                        matchFileEntries.put(name, r);
14
                    }
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.3
Clones locationClones are in different classes having the same super class
Number of node comparisons36
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)7.1
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                            
    12
    entry = (ZipEntry)e.nextElement();
    Preondition Violations
    Unmatched statement entry=(ZipEntry)e.nextElement(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12
    entry = (ZipEntry)e.nextElement();
    7
    Resource r = new TarResource(src, entry);
    7
    Resource r = new TarResource(src, entry);
    13
    Resource r = new ZipResource(srcFile, encoding, entry);
    Differences
    Expression1Expression2Difference
    org.apache.tools.ant.types.resources.TarResourceorg.apache.tools.ant.types.resources.ZipResourceSUBCLASS_TYPE_MISMATCH
    new TarResource(src,entry)new ZipResource(srcFile,encoding,entry)ARGUMENT_NUMBER_MISMATCH
    13
    Resource r = new ZipResource(srcFile, encoding, entry);
    8
    String name = entry.getName();
    8
    String name = entry.getName();
    14
    String name = entry.getName();
    Differences
    Expression1Expression2Difference
    org.apache.tools.tar.TarEntryorg.apache.tools.zip.ZipEntryVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.apache.tools.tar.TarEntry of variable entry does not match with type org.apache.tools.zip.ZipEntry of variable entry
    • Make classes org.apache.tools.tar.TarEntry and org.apache.tools.zip.ZipEntry extend a common superclass
    14
    String name = entry.getName();
    9
    if (entry.isDirectory())
    9
    if (entry.isDirectory())
    15
    if (entry.isDirectory())
    Differences
    Expression1Expression2Difference
    org.apache.tools.tar.TarEntryorg.apache.tools.zip.ZipEntryVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.apache.tools.tar.TarEntry of variable entry does not match with type org.apache.tools.zip.ZipEntry of variable entry
    • Make classes org.apache.tools.tar.TarEntry and org.apache.tools.zip.ZipEntry extend a common superclass
    15
    if (entry.isDirectory())
    10
    name = trimSeparator(name);
    16
    name = trimSeparator(name);
    11
    dirEntries.put(name, r);
    17
    dirEntries.put(name, r);
    12
    if (match(name))
    18
    if (match(name))
    13
    matchDirEntries.put(name, r);
    19
    matchDirEntries.put(name, r);
    else
    else
    14
    fileEntries.put(name, r);
    20
    fileEntries.put(name, r);
    15
    if (match(name))
    21
    if (match(name))
    16
    matchFileEntries.put(name, r);
    22
    matchFileEntries.put(name, r);
    Precondition Violations (3)
    Row Violation
    1Unmatched statement entry=(ZipEntry)e.nextElement(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Type org.apache.tools.tar.TarEntry of variable entry does not match with type org.apache.tools.zip.ZipEntry of variable entry
    3Type org.apache.tools.tar.TarEntry of variable entry does not match with type org.apache.tools.zip.ZipEntry of variable entry