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 | } | | | |
See real code fragment |
|
See real code fragment |
-
{Non-refactorable}
Mapping Summary
Number of mapped statements | 4 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 0.0 |
Similarity Score | 0.800 |
Clone type | Type 2 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
3 | while (itr.hasNext()) | | 2 | for (Iterator iterator = errorList.iterator(); iterator.hasNext(); ) |
| | | 3 | buf.append((String)iterator.next()); |
4 | | | | |
5 | | | 4 | |
6 | | | 5 | |
Precondition Violations (3)
Row |
Violation |
1 | Type java.util.Set of variable subProperties.keySet() does not match with type java.util.List of variable errorList |
2 | 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 | Clone fragment #1 returns variables , while Clone fragment #2 returns variables iterator |