if (filesets.isEmpty()) { return ""; } int count = 0; StringBuffer urls = new StringBuffer(); ListIterator list = filesets.listIterator(); while (list.hasNext()) { FileSet set = (FileSet) list.next(); DirectoryScanner scanner = set.getDirectoryScanner(getProject()); String[] files = scanner.getIncludedFiles(); for (int i = 0; i < files.length; i++) { File f = new File(scanner.getBasedir(), files[i]); validateFile(f); String asUrl = toURL(f); urls.append(asUrl); log(asUrl, Project.MSG_DEBUG); urls.append(separator); count++; } } //at this point there is one trailing space to remove, if the list is not empty. return stripTrailingSeparator(urls, count);
if (paths.isEmpty()) { return ""; } int count = 0; StringBuffer urls = new StringBuffer(); ListIterator list = paths.listIterator(); while (list.hasNext()) { Path path = (Path) list.next(); String[] elements = path.list(); for (int i = 0; i < elements.length; i++) { File f = new File(elements[i]); validateFile(f); String asUrl = toURL(f); urls.append(asUrl); log(asUrl, Project.MSG_DEBUG); urls.append(separator); count++; } } //at this point there is one trailing space to remove, if the list is not empty. return stripTrailingSeparator(urls, count);
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/MakeUrl.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/MakeUrl.java
Method name: String filesetsToURL() Method name: String pathsToURL()
Number of AST nodes: 18 Number of AST nodes: 17
1
if (filesets.isEmpty()) {
1
if (paths.isEmpty()) {
2
            return "";
2
            return "";
3
        }
3
        }
4
        int count = 0;
4
        int count = 0;
5
        StringBuffer urls = new StringBuffer();
5
        StringBuffer urls = new StringBuffer();
6
        ListIterator list = filesets.listIterator();
6
        ListIterator list = paths.listIterator();
7
        while (list.hasNext()) {
7
        while (list.hasNext()) {
8
            FileSet set = (FileSet) list.next();
8
            Path path = (Path) list.next();
9
            DirectoryScanner scanner = set.getDirectoryScanner(getProject());
10
            String[] files = scanner.getIncludedFiles();
9
            String[] elements = path.list();
11
            for (int i = 0; i < files.length; i++) {
10
            for (int i = 0; i < elements.length; i++) {
12
                File f = new File(scanner.getBasedir(), files[i]);
11
                File f = new File(elements[i]);
13
                validateFile(f);
12
                validateFile(f);
14
                String asUrl = toURL(f);
13
                String asUrl = toURL(f);
15
                urls.append(asUrl);
14
                urls.append(asUrl);
16
                log(asUrl, Project.MSG_DEBUG);
15
                log(asUrl, Project.MSG_DEBUG);
17
                urls.append(separator);
16
                urls.append(separator);
18
                count++;
17
                count++;
19
            }
18
            }
20
        }
19
        }
21
        //at this point there is one trailing space to remove, if the list is not empty.
20
        //at this point there is one trailing space to remove, if the list is not empty.
22
        return stripTrailingSeparator(urls, count);
21
        return stripTrailingSeparator(urls, count);
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 declared in the same class
Number of node comparisons90
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements16
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)6.3
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    if (filesets.isEmpty())
    1
    if (filesets.isEmpty())
    1
    if (paths.isEmpty())
    Differences
    Expression1Expression2Difference
    filesetspathsVARIABLE_NAME_MISMATCH
    1
    if (paths.isEmpty())
    2
    return "";
    2
    return "";
    3
    int count = 0;
    3
    int count = 0;
    4
    StringBuffer urls = new StringBuffer();
    4
    StringBuffer urls = new StringBuffer();
    5
    ListIterator list = filesets.listIterator();
    5
    ListIterator list = filesets.listIterator();
    5
    ListIterator list = paths.listIterator();
    Differences
    Expression1Expression2Difference
    filesetspathsVARIABLE_NAME_MISMATCH
    5
    ListIterator list = paths.listIterator();
    6
    while (list.hasNext())
    6
    while (list.hasNext())
    7
    FileSet set = (FileSet)list.next();
    7
    FileSet set = (FileSet)list.next();
    7
    Path path = (Path)list.next();
    Differences
    Expression1Expression2Difference
    org.apache.tools.ant.types.FileSetorg.apache.tools.ant.types.PathSUBCLASS_TYPE_MISMATCH
    setpathVARIABLE_NAME_MISMATCH
    org.apache.tools.ant.types.FileSetorg.apache.tools.ant.types.PathSUBCLASS_TYPE_MISMATCH
    org.apache.tools.ant.types.FileSetorg.apache.tools.ant.types.PathSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (FileSet)list.next() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (Path)list.next() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7
    Path path = (Path)list.next();
                                                                      
    8
    String[] elements = path.list();
    Preondition Violations
    Unmatched statement String[] elements=path.list(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8
    String[] elements = path.list();
    8
    DirectoryScanner scanner = set.getDirectoryScanner(getProject());
    8
    DirectoryScanner scanner = set.getDirectoryScanner(getProject());
    Preondition Violations
    Unmatched statement DirectoryScanner scanner=set.getDirectoryScanner(getProject()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                        
    9
    String[] files = scanner.getIncludedFiles();
    9
    String[] files = scanner.getIncludedFiles();
    Preondition Violations
    Unmatched statement String[] files=scanner.getIncludedFiles(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                              
    10
    for (int i = 0; i < files.length; i++)
    10
    for (int i = 0; i < files.length; i++)
    9
    for (int i = 0; i < elements.length; i++)
    Differences
    Expression1Expression2Difference
    fileselementsVARIABLE_NAME_MISMATCH
    9
    for (int i = 0; i < elements.length; i++)
    11
    File f = new File(scanner.getBasedir(), files[i]);
    11
    File f = new File(scanner.getBasedir(), files[i]);
    10
    File f = new File(elements[i]);
    Differences
    Expression1Expression2Difference
    new File(scanner.getBasedir(),files[i])new File(elements[i])ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression new File(scanner.getBasedir(),files[i]) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new File(elements[i]) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10
    File f = new File(elements[i]);
    12
    validateFile(f);
    11
    validateFile(f);
    13
    String asUrl = toURL(f);
    12
    String asUrl = toURL(f);
    14
    urls.append(asUrl);
    13
    urls.append(asUrl);
    15
    log(asUrl, Project.MSG_DEBUG);
    14
    log(asUrl, Project.MSG_DEBUG);
    16
    urls.append(separator);
    15
    urls.append(separator);
    17
    count++;
    16
    count++;
    18
    return stripTrailingSeparator(urls, count);
    17
    return stripTrailingSeparator(urls, count);
    Precondition Violations (8)
    Row Violation
    1Expression (FileSet)list.next() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression (Path)list.next() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Unmatched statement String[] elements=path.list(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement DirectoryScanner scanner=set.getDirectoryScanner(getProject()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement String[] files=scanner.getIncludedFiles(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Expression new File(scanner.getBasedir(),files[i]) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression new File(elements[i]) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Clone fragment #1 returns variable set with type org.apache.tools.ant.types.FileSet , while Clone fragment #2 returns variable path with type org.apache.tools.ant.types.Path