130-1-3

while ((ch = patArr[patIdxEnd]) != '*' && strIdxStart <= strIdxEnd) { if (ch != '?') { if (isCaseSensitive && ch != strArr[strIdxEnd]) { return false; // Character mismatch } if (!isCaseSensitive && Character.toUpperCase(ch) != Character.toUpperCase(strArr[strIdxEnd])) { return false; // Character mismatch } } patIdxEnd--; strIdxEnd--; }
for (int i = 0; i <= patIdxEnd; i++) { ch = patArr[i]; if (ch != '?') { if (isCaseSensitive && ch != strArr[i]) { return false; // Character mismatch } if (!isCaseSensitive && Character.toUpperCase(ch) != Character.toUpperCase(strArr[i])) { return false; // Character mismatch } } }

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

1

    while ((ch = patArr[patIdxEnd]) != '*' && strIdxStart <= strIdxEnd) {↵

1

    for (int i = 0; i <= patIdxEnd; i++) {↵

2

                    ch = patArr[i];↵

2

                if (ch != '?') {↵

3

                    if (ch != '?') {↵

3

                    if (isCaseSensitive && ch != strArr[strIdxEnd]) {↵

4

                        if (isCaseSensitive && ch != strArr[i]) {↵

4

                        return false; // Character mismatch↵

5

                            return false; // Character mismatch↵

5

                    }↵

6

                    ↵

7

        }↵

6

                    if (!isCaseSensitive && Character.toUpperCase(ch)↵

8

                        if (!isCaseSensitive && Character.toUpperCase(ch)↵

7

                            != Character.toUpperCase(strArr[strIdxEnd])) {↵

9

                                != Character.toUpperCase(strArr[i])) {↵

8

                        return false; // Character mismatch↵

10

                            return false;  // Character mismatch↵

9

                    }↵

11

              ↵

10

                }↵

12

              }↵

11

                patIdxEnd--;↵

13

              ↵

12

            ↵

14

          }↵

13

        strIdxEnd--;↵

15

        ↵

14

            }

16

            }

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.8
Clones location | Clones are in the same method
Number of node comparisons | 15

1. {Non-refactorable}

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

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

   17 | ch = patArr[i];

   Preondition Violations
   Unmatched statement ch=patArr[i]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   17

       ch = patArr[i];

   40

       if (ch != '?')

   18

       if (ch != '?')

   41

       if (isCaseSensitive && ch != strArr[strIdxEnd])

   41 | if (isCaseSensitive && ch != strArr[strIdxEnd])
   19 | if (isCaseSensitive && ch != strArr[i])

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   strIdxEnd | i | VARIABLE_NAME_MISMATCH

   19

       if (isCaseSensitive && ch != strArr[i])

   42

       return false;

   42 | return false;
   20 | return false;

   Preondition Violations
   Conditional return false;
   Conditional return false;

   20

       return false;

   43

       if (!isCaseSensitive && Character.toUpperCase(ch) != Character.toUpperCase(strArr[strIdxEnd]))

   43 | if (! isCaseSensitive && Character.toUpperCase(ch) != Character.toUpperCase(strArr[strIdxEnd]))
   21 | if (! isCaseSensitive && Character.toUpperCase(ch) != Character.toUpperCase(strArr[i]))

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   strIdxEnd | i | VARIABLE_NAME_MISMATCH

   21

       if (!isCaseSensitive && Character.toUpperCase(ch) != Character.toUpperCase(strArr[i]))

   44

       return false;

   44 | return false;
   22 | return false;

   Preondition Violations
   Conditional return false;
   Conditional return false;

   22

       return false;

   Precondition Violations (5)
   Row | Violation
   --- | ---
   1 | Unmatched statement ch=patArr[i]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   2 | Conditional return false;
   3 | Conditional return false;
   4 | Conditional return false;
   5 | Conditional return false;