private String keyString() { StringBuffer buff = new StringBuffer(); Iterator itr = subProperties.keySet().iterator(); while ( itr.hasNext() ) { buff.append( itr.next() ); if ( itr.hasNext() ) { buff.append( ", " ); } } return buff.toString(); }
private String getErrorString() { StringBuffer buf = new StringBuffer(); for ( Iterator iterator = errorList.iterator(); iterator.hasNext(); ) { buf.append( ( String ) iterator.next() ); if ( iterator.hasNext() ) buf.append( "\n" ); } return buf.toString(); }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/any/ComplexPropertyValue.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/hql/ast/ErrorCounter.java
Method name: String keyString() Method name: String getErrorString()
Number of AST nodes: 4 Number of AST nodes: 4
1
private String keyString() {
1
private String getErrorString() {
2
		StringBuffer buff = new StringBuffer();
2
		StringBuffer buf = new StringBuffer();
3
		Iterator itr = subProperties.keySet().iterator();
3
		for ( Iterator iterator = errorList.iterator(); iterator.hasNext(); ) {
4
		while ( itr.hasNext() ) {
4
			buf.append( ( String ) iterator.next() );
5
			buff.append( itr.next() );
5
			if ( iterator.hasNext() ) buf.append( "\n" );
6
			if ( itr.hasNext() ) {
6
7
				buff.append( ", " );
7
		}
8
			}
8
		return buf.toString();
9
		}
9
	}
10
		return buff.toString();
11
	}
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.800
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    3
    while (itr.hasNext())
    3
    while (itr.hasNext())
    2
    for (Iterator iterator = errorList.iterator(); iterator.hasNext(); )
    Differences
    Expression1Expression2Difference
    itriteratorVARIABLE_NAME_MISMATCH
    java.util.Setjava.util.ListVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Set of variable subProperties.keySet() does not match with type java.util.List of variable errorList
    • Make classes java.util.Set and java.util.List extend a common superclass
    2
    for (Iterator iterator = errorList.iterator(); iterator.hasNext(); )
                                                                                  
    3
    buf.append((String)iterator.next());
    Preondition Violations
    Unmatched statement buf.append((String)iterator.next()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    buf.append((String)iterator.next());
    4
    buff.append(itr.next());
                                                          
    5
    if (itr.hasNext())
    5
    if (itr.hasNext())
    4
    if (iterator.hasNext())
    Differences
    Expression1Expression2Difference
    itriteratorVARIABLE_NAME_MISMATCH
    4
    if (iterator.hasNext())
    6
    buff.append(", ");
    6
    buff.append(", ");
    5
    buf.append("\n");
    Differences
    Expression1Expression2Difference
    ", ""\n"LITERAL_VALUE_MISMATCH
    buffbufVARIABLE_NAME_MISMATCH
    5
    buf.append("\n");
    Precondition Violations (3)
    Row Violation
    1Type java.util.Set of variable subProperties.keySet() does not match with type java.util.List of variable errorList
    2Unmatched statement buf.append((String)iterator.next()); 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 , while Clone fragment #2 returns variables iterator