151-1-2

if (!supportsSymlinks) { return; } getProject().executeTarget("symlink-setup"); DirectoryScanner ds = new DirectoryScanner(); ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); ds.setIncludes(new String[] {"alpha/beta/gamma/"}); ds.setFollowSymlinks(false); ds.scan(); compareFiles(ds, new String[] {}, new String[] {});
if (!supportsSymlinks) { return; } getProject().executeTarget("symlink-setup"); DirectoryScanner ds = new DirectoryScanner(); ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); ds.setIncludes(new String[] {"alpha/beta/gamma/"}); ds.scan(); compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, new String[] {"alpha/beta/gamma"});

Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java |  | File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java
Method name: `void testProhibitSymlinks()` |  | Method name: `void testAllowSymlinks()`
Number of AST nodes: 9 |  | Number of AST nodes: 8

1

    if (!supportsSymlinks) {↵

1

    if (!supportsSymlinks) {↵

2

                return;↵

2

                return;↵

3

            }↵

3

            }↵

4

            getProject().executeTarget("symlink-setup");↵

4

            getProject().executeTarget("symlink-setup");↵

5

            DirectoryScanner ds = new DirectoryScanner();↵

5

            DirectoryScanner ds = new DirectoryScanner();↵

6

            ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));↵

6

            ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));↵

7

            ds.setIncludes(new String[] {"alpha/beta/gamma/"});↵

7

            ds.setIncludes(new String[] {"alpha/beta/gamma/"});↵

8

            ds.setFollowSymlinks(false);↵

9

            ds.scan();↵

8

            ds.scan();↵

10

            compareFiles(ds, new String[] {}, new String[] {↵

9

            compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"},↵

11

    });

10

                         new String[] {"alpha/beta/gamma"});

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 0
Number of non-refactorable cases | 1
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.1
Clones location | Clones are declared in the same class
Number of node comparisons | 30

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 8
   Number of unmapped statements in the first code fragment | 1
   Number of unmapped statements in the second code fragment | 0
   Time elapsed for statement mapping (ms) | 2.4
   Clone type | Type 3

   Mapped Statements
   ID | Statement |  | ID | Statement
   --- | --- | --- | --- | ---

   1

       if (!supportsSymlinks)

   1

       if (!supportsSymlinks)

   2

       return;

   2

       return;

   3

       getProject().executeTarget("symlink-setup");

   3

       getProject().executeTarget("symlink-setup");

   4

       DirectoryScanner ds = new DirectoryScanner();

   4

       DirectoryScanner ds = new DirectoryScanner();

   5

       ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));

   5

       ds.setBasedir(new File(getProject().getBaseDir(), "tmp"));

   6

       ds.setIncludes(new String[] {"alpha/beta/gamma/"});

   6

       ds.setIncludes(new String[] {"alpha/beta/gamma/"});

   7

       ds.setFollowSymlinks(false);

   7 | ds.setFollowSymlinks(false);

   Preondition Violations
   Unmatched statement ds.setFollowSymlinks(false); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   8

       ds.scan();

   7

       ds.scan();

   9

       compareFiles(ds, new String[] {}, new String[] {});

   9 | compareFiles(ds, new String[] {}, new String[] {});
   8 | compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, new String[] {"alpha/beta/gamma"});

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   {} | {"alpha/beta/gamma/gamma.xml"} | ARRAY_INITIALIZER_EXPRESSION_NUMBER_MISMATCH
   {} | {"alpha/beta/gamma"} | ARRAY_INITIALIZER_EXPRESSION_NUMBER_MISMATCH

   8

       compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, new String[] {"alpha/beta/gamma"});

   Precondition Violations (2)
   Row | Violation
   --- | ---
   1 | Unmatched statement ds.setFollowSymlinks(false); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   2 | Clone fragment #1 returns variables ds , while Clone fragment #2 returns variables