StringBuffer buf = new StringBuffer();
if (hasSelectors()) {
buf.append("{majorityselect: ");
buf.append(super.toString());
buf.append("}");
}
return buf.toString();
executeTarget("test5");
java.io.File f = new java.io.File(getProjectDir(), "copyfile.tmp");
if (f.exists()) {
f.delete();
} else {
fail("Copy failed");
}
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/types/selectors/MajoritySelector.java
|
|
File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/taskdefs/CopyfileTest.java
|
Method name: String toString()
|
|
Method name: void test5()
|
Number of AST nodes: 6
|
|
Number of AST nodes: 5
|
|
1 | StringBuffer buf = new StringBuffer(↵ | | 1 | executeTarget("test5");↵
|
2 | );↵ | | 2 | java.io.File f = new java.io.File(getProjectDir(), "copyfile.tmp");↵
|
3 | if (hasSelectors()) {↵ | | 3 | if (f.exists()) {↵
|
4 | buf.append("{majorityselect: ");↵ | | 4 | ↵
|
5 | buf.append(super.toString());↵ | | |
|
6 | buf.append("}");↵ | | |
|
7 | }↵ | | |
|
8 | return buf.toString(); | | 5 | f.delete();↵
|
| | | 6 | } else {↵
|
| | | 7 | fail("Copy failed");↵
|
| | | 8 | }
|
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.1 |
Clones location | Clones are in different classes |
Number of node comparisons | 16 |
-
{Non-refactorable}
Mapping Summary
Number of mapped statements | 1 |
Number of unmapped statements in the first code fragment | 5 |
Number of unmapped statements in the second code fragment | 4 |
Time elapsed for statement mapping (ms) | 0.9 |
Clone type | Type 3 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
| | | 1 | executeTarget("test5"); |
1 | StringBuffer buf = new StringBuffer(); | | | |
| | | 2 | java.io.File f = new java.io.File(getProjectDir(), "copyfile.tmp"); |
2 | if (hasSelectors()) | | 3 | if (f.exists()) |
3 | buf.append("{majorityselect: "); | | | |
| | | 4 | |
4 | buf.append(super.toString()); | | | |
| | | | |
| | | 5 | |
5 | | | | |
6 | return buf.toString(); | | | |
Precondition Violations (2)
Row |
Violation |
1 | Unmatched statement f.delete(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched return buf.toString(); |