index++; start = index; while (index < end) { testChar = p_uriSpec.charAt(index); if (testChar == '#') { break; } if (testChar == '%') { if (index+2 >= end || !isHex(p_uriSpec.charAt(index+1)) || !isHex(p_uriSpec.charAt(index+2))) { throw new MalformedURIException( "Query string contains invalid escape sequence!"); } index += 2; } else if (!isURICharacter(testChar)) { throw new MalformedURIException( "Query string contains invalid character: " + testChar); } index++; } m_queryString = p_uriSpec.substring(start, index);
if (testChar == '#') { index++; start = index; while (index < end) { testChar = p_uriSpec.charAt(index); if (testChar == '%') { if (index+2 >= end || !isHex(p_uriSpec.charAt(index+1)) || !isHex(p_uriSpec.charAt(index+2))) { throw new MalformedURIException( "Fragment contains invalid escape sequence!"); } index += 2; } else if (!isURICharacter(testChar)) { throw new MalformedURIException( "Fragment contains invalid character: "+testChar); } index++; } m_fragment = p_uriSpec.substring(start, index); }
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: void initializePath(String, int) Method name: void initializePath(String, int)
Number of AST nodes: 14 Number of AST nodes: 13
1
if (testChar == '#') {
1
index++;
2
      index++;
2
      start = index;
3
      start = index;
3
      while (index < end) {
4
      while (index < end) {
4
        testChar = p_uriSpec.charAt(index);
5
        testChar = p_uriSpec.charAt(index);
5
        if (testChar == '#') {
6
          break;
7
        }
8
        if (testChar == '%') {
6
        if (testChar == '%') {
9
           if (index+2 >= end ||
7
           if (index+2 >= end ||
10
              !isHex(p_uriSpec.charAt(index+1)) ||
8
              !isHex(p_uriSpec.charAt(index+1)) ||
11
              !isHex(p_uriSpec.charAt(index+2))) {
9
              !isHex(p_uriSpec.charAt(index+2))) {
12
            throw new MalformedURIException(
10
            throw new MalformedURIException(
13
                    "Query string contains invalid escape sequence!");
11
                    "Fragment contains invalid escape sequence!");
14
           }
12
           }
15
           index += 2;
13
           index += 2;
16
        }
14
        }
17
        else if (!isURICharacter(testChar)) {
15
        else if (!isURICharacter(testChar)) {
18
          throw new MalformedURIException(
16
          throw new MalformedURIException(
19
                "Query string contains invalid character: " + testChar);
17
                "Fragment contains invalid character: "+testChar);
20
        }
18
        }
21
        index++;
19
        index++;
22
      }
20
      }
23
      m_queryString = p_uriSpec.substring(start, index);
21
      m_fragment = p_uriSpec.substring(start, index);
22
    }
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.8
Clones locationClones are in the same method
Number of node comparisons38
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements11
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)3.6
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    33
    index++;
    48
    index++;
    34
    start = index;
    49
    start = index;
    35
    while (index < end)
    50
    while (index < end)
    36
    testChar = p_uriSpec.charAt(index);
    51
    testChar = p_uriSpec.charAt(index);
    37
    if (testChar == '#')
    37
    if (testChar == '#')
    Preondition Violations
    Unmatched statement if(testChar == '#') cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                  
    38
    break;
    38
    break;
    Preondition Violations
    Unmatched break;
                        
    39
    if (testChar == '%')
    52
    if (testChar == '%')
    40
    if (index + 2 >= end || !isHex(p_uriSpec.charAt(index + 1)) || !isHex(p_uriSpec.charAt(index + 2)))
    53
    if (index + 2 >= end || !isHex(p_uriSpec.charAt(index + 1)) || !isHex(p_uriSpec.charAt(index + 2)))
    41
    throw new MalformedURIException("Query string contains invalid escape sequence!");
    41
    throw new MalformedURIException("Query string contains invalid escape sequence!");
    54
    throw new MalformedURIException("Fragment contains invalid escape sequence!");
    Differences
    Expression1Expression2Difference
    "Query string contains invalid escape sequence!""Fragment contains invalid escape sequence!"LITERAL_VALUE_MISMATCH
    54
    throw new MalformedURIException("Fragment contains invalid escape sequence!");
    42
    index += 2;
    55
    index += 2;
    43
    else if (!isURICharacter(testChar))
    56
    else if (!isURICharacter(testChar))
    44
    throw new MalformedURIException("Query string contains invalid character: " + testChar);
    44
    throw new MalformedURIException("Query string contains invalid character: " + testChar);
    57
    throw new MalformedURIException("Fragment contains invalid character: " + testChar);
    Differences
    Expression1Expression2Difference
    "Query string contains invalid character: ""Fragment contains invalid character: "LITERAL_VALUE_MISMATCH
    57
    throw new MalformedURIException("Fragment contains invalid character: " + testChar);
    45
    index++;
    58
    index++;
    Precondition Violations (3)
    Row Violation
    1Unmatched statement if(testChar == '#') cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched break;
    3Clone fragment #1 returns variables testChar, index, start , while Clone fragment #2 returns variables index, start