IRubyObject tcpServer = recv.callMethod(context, "new", args);
if (!block.isGiven()) return tcpServer;
try {
return block.yield(context, tcpServer);
} finally {
tcpServer.callMethod(context, "close");
}
RubyTCPSocket sock = (RubyTCPSocket)recv.callMethod(context,"new",args);
if (!block.isGiven()) return sock;
try {
return block.yield(context, sock);
} finally {
if (sock.openFile.isOpen()) sock.close();
}
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/ext/socket/RubyTCPServer.java
|
|
File path: /jruby-1.4.0/src/org/jruby/ext/socket/RubyTCPSocket.java
|
Method name: IRubyObject open(ThreadContext, IRubyObject, IRubyObject[], Block)
|
|
Method name: IRubyObject open(ThreadContext, IRubyObject, IRubyObject[], Block)
|
Number of AST nodes: 5
|
|
Number of AST nodes: 5
|
|
1 | IRubyObject tcpServer = recv.callMethod(context, "new", args);↵ | | 1 | RubyTCPSocket sock = (RubyTCPSocket)recv.callMethod(context,"new",args);↵
|
2 | ↵ | | |
|
3 | if (!block.isGiven()) return tcpServer;↵ | | 2 | if (!block.isGiven()) return ↵
|
4 | ↵ | | 3 | sock;↵
|
|
5 | try {↵ | | 4 | try {↵
|
6 | return block.yield(context, tcpServer);↵ | | 5 | return block.yield(context, sock);↵
|
7 | } finally {↵ | | 6 | } finally {↵
|
8 | tcpServer.callMethod(context, "close");↵ | | 7 | if (sock.openFile.isOpen()) sock.close();↵
|
9 | } | | 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.2 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 8 |
-
{Non-refactorable}
Mapping Summary
Number of mapped statements | 1 |
Number of unmapped statements in the first code fragment | 2 |
Number of unmapped statements in the second code fragment | 2 |
Time elapsed for statement mapping (ms) | 0.6 |
Clone type | Type 2 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
| | | 1 | RubyTCPSocket sock = (RubyTCPSocket)recv.callMethod(context, "new", args); |
1 | IRubyObject tcpServer = recv.callMethod(context, "new", args); | | | |
2 | if (!block.isGiven()) | | 2 | if (!block.isGiven()) |
| | | 3 | |
3 | | | | |
Precondition Violations (2)
Row |
Violation |
1 | Unmatched return sock; |
2 | Unmatched return tcpServer; |