128-1-3

validate(); Enumeration e = selectorElements(); boolean result; while (e.hasMoreElements()) { result = ((FileSelector) e.nextElement()).isSelected(basedir, filename, file); if (result) { return false; } } return true;
validate(); Enumeration e = selectorElements(); boolean result; while (e.hasMoreElements()) { result = ((FileSelector) e.nextElement()).isSelected(basedir, filename, file); if (!result) { return false; } } return true;

Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/types/selectors/NoneSelector.java |  | File path: /apache-ant-1.7.0/src/org/apache/tools/ant/types/selectors/AndSelector.java
Method name: `boolean isSelected(File, String, File)` |  | Method name: `boolean isSelected(File, String, File)`
Number of AST nodes: 8 |  | Number of AST nodes: 8

1

    validate();↵

1

    validate();↵

2

            Enumeration e = selectorElements();↵

2

            Enumeration e = selectorElements();↵

3

            boolean result;↵

3

            boolean result;↵

4

            while (e.hasMoreElements()) {↵

4

            while (e.hasMoreElements()) {↵

5

                result = ((FileSelector) e.nextElement()).isSelected(basedir,↵

5

                result = ((FileSelector) e.nextElement()).isSelected(basedir,↵

6

                        filename, file);↵

6

                        filename, file);↵

7

                if (result) {↵

7

                if (!result) {↵

8

                    return false;↵

8

                    return false;↵

9

                }↵

9

                }↵

10

            }↵

10

            }↵

11

            return true;

11

            return true;

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 in different classes having the same super class
Number of node comparisons | 24

1. {Non-refactorable}

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

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

   1

       validate();

   1

       validate();

   2

       Enumeration e = selectorElements();

   2

       Enumeration e = selectorElements();

   3

       boolean result;

   3

       boolean result;

   4

       while (e.hasMoreElements())

   4

       while (e.hasMoreElements())

   5

       result = ((FileSelector)e.nextElement()).isSelected(basedir, filename, file);

   5

       result = ((FileSelector)e.nextElement()).isSelected(basedir, filename, file);

   6

       if (result)

   6 | if (result)
   6 | if (! result)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   result | !result | TYPE_COMPATIBLE_REPLACEMENT

   Preondition Violations
   Expression result cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression !result cannot be parameterized, because it has dependencies to/from statements that will be extracted

   6

       if (!result)

   7

       return false;

   7

       return false;

   8

       return true;

   8

       return true;

   Precondition Violations (2)
   Row | Violation
   --- | ---
   1 | Expression result cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression !result cannot be parameterized, because it has dependencies to/from statements that will be extracted