int index = 0; int end = userinfo.length(); char testChar = '\0'; while (index < end) { testChar = userinfo.charAt(index); if (testChar == '%') { if (index+2 >= end || !isHex(userinfo.charAt(index+1)) || !isHex(userinfo.charAt(index+2))) { return false; } index += 2; } else if (!isUserinfoCharacter(testChar)) { return false; } ++index; }
int index = 0; int end = authority.length(); char testChar; while (index < end) { testChar = authority.charAt(index); // check for valid escape sequence if (testChar == '%') { if (index+2 >= end || !isHex(authority.charAt(index+1)) || !isHex(authority.charAt(index+2))) { return false; } index += 2; } // can check against path characters because the set // is the same except for '/' which we've already excluded. else if (!isPathCharacter(testChar)) { return false; } ++index; } return true;
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/xml/type/internal/DataValue.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/xml/type/internal/DataValue.java
Method name: boolean isValidServerBasedAuthority(String, int, String) Method name: boolean isValidRegistryBasedAuthority(String)
Number of AST nodes: 12 Number of AST nodes: 13
1
int index = 0;
1
int index = 0;
2
      int end = userinfo.length();
2
    int end = authority.length();
3
      char testChar = '\0';
3
    char testChar;
4
    
4
    
5
  while (index < end) {
5
    while (index < end) {
6
        testChar = userinfo.charAt(index);
6
      testChar = authority.charAt(index);
7
      
7
      
8
      // check for valid escape sequence
8
  if (testChar == '%') {
9
      if (testChar == '%') {
9
          if (index+2 >= end ||
10
        if (index+2 >= end ||
10
            !isHex(userinfo.charAt(index+1)) ||
11
            !isHex(authority.charAt(index+1)) ||
11
            !isHex(userinfo.charAt(index+2))) {
12
            !isHex(authority.charAt(index+2))) {
12
            return false;
13
            return false;
13
          }
14
        
14
  
15
}
15
        index += 2;
16
        index += 2;
16
        }
17
      }
17
  
18
      // can check against path characters because the set
19
      // is the same except for '/' which we've already excluded.
18
      else if (!isUserinfoCharacter(testChar)) {
20
      else if (!isPathCharacter(testChar)) {
19
          return false;
21
        return false;
20
        }
22
      }
21
        ++index;
23
      ++index;
22
      }
24
    }
25
    return true;
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 comparisons33
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements11
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)1.9
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    6
    int index = 0;
    1
    int index = 0;
    7
    int end = userinfo.length();
    7
    int end = userinfo.length();
    2
    int end = authority.length();
    Differences
    Expression1Expression2Difference
    userinfoauthorityVARIABLE_NAME_MISMATCH
    2
    int end = authority.length();
                                      
    3
    char testChar;
    8
    char testChar = '\0';
                                                
    9
    while (index < end)
    4
    while (index < end)
    10
    testChar = userinfo.charAt(index);
    10
    testChar = userinfo.charAt(index);
    5
    testChar = authority.charAt(index);
    Differences
    Expression1Expression2Difference
    userinfoauthorityVARIABLE_NAME_MISMATCH
    5
    testChar = authority.charAt(index);
    11
    if (testChar == '%')
    6
    if (testChar == '%')
    12
    if (index + 2 >= end || !isHex(userinfo.charAt(index + 1)) || !isHex(userinfo.charAt(index + 2)))
    12
    if (index + 2 >= end || !isHex(userinfo.charAt(index + 1)) || !isHex(userinfo.charAt(index + 2)))
    7
    if (index + 2 >= end || !isHex(authority.charAt(index + 1)) || !isHex(authority.charAt(index + 2)))
    Differences
    Expression1Expression2Difference
    userinfoauthorityVARIABLE_NAME_MISMATCH
    userinfoauthorityVARIABLE_NAME_MISMATCH
    7
    if (index + 2 >= end || !isHex(authority.charAt(index + 1)) || !isHex(authority.charAt(index + 2)))
    13
    return false;
    8
    return false;
    14
    index += 2;
    9
    index += 2;
    15
    else if (!isUserinfoCharacter(testChar))
    15
    else if (!isUserinfoCharacter(testChar))
    10
    else if (!isPathCharacter(testChar))
    Differences
    Expression1Expression2Difference
    isUserinfoCharacterisPathCharacterMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression isUserinfoCharacter(testChar) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method isUserinfoCharacter
    Expression isPathCharacter(testChar) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method isPathCharacter
    10
    else if (!isPathCharacter(testChar))
    16
    return false;
    11
    return false;
    17
    ++index;
    12
    ++index;
                                    
    13
    return true;
    Preondition Violations
    Unmatched return true;
    13
    return true;
    Precondition Violations (3)
    Row Violation
    1Expression isUserinfoCharacter(testChar) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression isPathCharacter(testChar) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Unmatched return true;