156-1-2

String l = normalize(leading.getAbsolutePath()).getAbsolutePath(); String p = normalize(path.getAbsolutePath()).getAbsolutePath(); if (l.equals(p)) { return ""; } // ensure that l ends with a / // so we never think /foo was a parent directory of /foobar if (!l.endsWith(File.separator)) { l += File.separator; } return (p.startsWith(l)) ? p.substring(l.length()) : p;
String l = normalize(leading.getAbsolutePath()).getAbsolutePath(); String p = normalize(path.getAbsolutePath()).getAbsolutePath(); if (l.equals(p)) { return true; } // ensure that l ends with a / // so we never think /foo was a parent directory of /foobar if (!l.endsWith(File.separator)) { l += File.separator; } return p.startsWith(l);

Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/util/FileUtils.java |  | File path: /apache-ant-1.7.0/src/org/apache/tools/ant/util/FileUtils.java
Method name: `String removeLeadingPath(File, File)` |  | Method name: `boolean isLeadingPath(File, File)`
Number of AST nodes: 7 |  | Number of AST nodes: 7

1

    String l = normalize(leading.getAbsolutePath()).getAbsolutePath();↵

1

    String l = normalize(leading.getAbsolutePath()).getAbsolutePath();↵

2

            String p = normalize(path.getAbsolutePath()).getAbsolutePath();↵

2

            String p = normalize(path.getAbsolutePath()).getAbsolutePath();↵

3

            if (l.equals(p)) {↵

3

            if (l.equals(p)) {↵

4

                return "";↵

4

                return true;↵

5

            }↵

5

            }↵

6

            // ensure that l ends with a /↵

6

            // ensure that l ends with a /↵

7

            // so we never think /foo was a parent directory of /foobar↵

7

            // so we never think /foo was a parent directory of /foobar↵

8

            if (!l.endsWith(File.separator)) {↵

8

            if (!l.endsWith(File.separator)) {↵

9

                l += File.separator;↵

9

                l += File.separator;↵

10

            }↵

10

            }↵

11

            return (p.startsWith(l)) ? p.substring(l.length()) : p;

11

            return p.startsWith(l);

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.3
Clones location | Clones are declared in the same class
Number of node comparisons | 22

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 5
   Number of unmapped statements in the first code fragment | 2
   Number of unmapped statements in the second code fragment | 2
   Time elapsed for statement mapping (ms) | 1.4
   Clone type | Type 2

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

   1

       String l = normalize(leading.getAbsolutePath()).getAbsolutePath();

   1

       String l = normalize(leading.getAbsolutePath()).getAbsolutePath();

   2

       String p = normalize(path.getAbsolutePath()).getAbsolutePath();

   2

       String p = normalize(path.getAbsolutePath()).getAbsolutePath();

   3

       if (l.equals(p))

   3

       if (l.equals(p))

   4 | return true;

   Preondition Violations
   Unmatched return true;

   4

       return true;

   4

       return "";

   4 | return "";

   Preondition Violations
   Unmatched return "";

   5

       if (!l.endsWith(File.separator))

   5

       if (!l.endsWith(File.separator))

   6

       l += File.separator;

   6

       l += File.separator;

   7

       return p.startsWith(l);

   7

       return (p.startsWith(l)) ? p.substring(l.length()) : p;

   Precondition Violations (3)
   Row | Violation
   --- | ---
   1 | Unmatched return true;
   2 | Unmatched return "";
   3 | Clone fragment #1 returns variables l, p , while Clone fragment #2 returns variables l, p