String[] patDirs = tokenizePathAsArray(pattern); String[] strDirs = tokenizePathAsArray(str); int patIdxStart = 0; int patIdxEnd = patDirs.length - 1; int strIdxStart = 0; int strIdxEnd = strDirs.length - 1; // up to first '**' while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { String patDir = patDirs[patIdxStart]; if (patDir.equals("**")) { break; } if (!match(patDir, strDirs[strIdxStart], isCaseSensitive)) { return false; } patIdxStart++; strIdxStart++; }
String[] patDirs = tokenizePathAsArray(pattern); String[] strDirs = tokenizePathAsArray(str); int patIdxStart = 0; int patIdxEnd = patDirs.length - 1; int strIdxStart = 0; int strIdxEnd = strDirs.length - 1; // up to first '**' while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { String patDir = patDirs[patIdxStart]; if (patDir.equals("**")) { break; } if (!match(patDir, strDirs[strIdxStart], isCaseSensitive)) { patDirs = null; strDirs = null; return false; } patIdxStart++; strIdxStart++; }
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 matchPatternStart(String, String, boolean) Method name: boolean matchPath(String, String, boolean)
Number of AST nodes: 14 Number of AST nodes: 16
1
String[] patDirs = tokenizePathAsArray(pattern);
1
String[] patDirs = tokenizePathAsArray(pattern);
2
        String[] strDirs = tokenizePathAsArray(str);
2
        String[] strDirs = tokenizePathAsArray(str);
3
        int patIdxStart = 0;
3
        int patIdxStart = 0;
4
        int patIdxEnd = patDirs.length - 1;
4
        int patIdxEnd = patDirs.length - 1;
5
        int strIdxStart = 0;
5
        int strIdxStart = 0;
6
        int strIdxEnd = strDirs.length - 1;
6
        int strIdxEnd = strDirs.length - 1;
7
        // up to first '**'
7
        // up to first '**'
8
        while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) {
8
        while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) {
9
            String patDir = patDirs[patIdxStart];
9
            String patDir = patDirs[patIdxStart];
10
            if (patDir.equals("**")) {
10
            if (patDir.equals("**")) {
11
                break;
11
                break;
12
            }
12
            }
13
            if (!match(patDir, strDirs[strIdxStart], isCaseSensitive)) {
13
            if (!match(patDir, strDirs[strIdxStart], isCaseSensitive)) {
14
                patDirs = null;
15
                strDirs = null;
14
                return false;
16
                return false;
15
            }
17
            }
16
            patIdxStart++;
18
            patIdxStart++;
17
            strIdxStart++;
19
            strIdxStart++;
18
        }
20
        }
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.7
Clones locationClones are declared in the same class
Number of node comparisons73
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements14
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)6.7
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    3
    String[] patDirs = tokenizePathAsArray(pattern);
    1
    String[] patDirs = tokenizePathAsArray(pattern);
    4
    String[] strDirs = tokenizePathAsArray(str);
    2
    String[] strDirs = tokenizePathAsArray(str);
    5
    int patIdxStart = 0;
    3
    int patIdxStart = 0;
    6
    int patIdxEnd = patDirs.length - 1;
    4
    int patIdxEnd = patDirs.length - 1;
    7
    int strIdxStart = 0;
    5
    int strIdxStart = 0;
    8
    int strIdxEnd = strDirs.length - 1;
    6
    int strIdxEnd = strDirs.length - 1;
    9
    while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd)
    7
    while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd)
    10
    String patDir = patDirs[patIdxStart];
    8
    String patDir = patDirs[patIdxStart];
    11
    if (patDir.equals("**"))
    9
    if (patDir.equals("**"))
    12
    break;
    10
    break;
    13
    if (!match(patDir, strDirs[strIdxStart], isCaseSensitive))
    11
    if (!match(patDir, strDirs[strIdxStart], isCaseSensitive))
                                      
    12
    patDirs = null;
    Preondition Violations
    Unmatched statement patDirs=null; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12
    patDirs = null;
                                      
    13
    strDirs = null;
    Preondition Violations
    Unmatched statement strDirs=null; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13
    strDirs = null;
    14
    return false;
    14
    return false;
    15
    patIdxStart++;
    15
    patIdxStart++;
    16
    strIdxStart++;
    16
    strIdxStart++;
    Precondition Violations (4)
    Row Violation
    1Unmatched statement patDirs=null; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement strDirs=null; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Clone fragment #1 returns variables strIdxStart, strIdxEnd, patIdxStart, patIdxEnd , while Clone fragment #2 returns variables patDirs, strDirs, strIdxStart, strIdxEnd, patIdxStart, patIdxEnd
    4Not all possible execution flows end in a return statement