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
        }
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.2
Clones locationClones are in different classes having the same super class
Number of node comparisons8
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements1
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)0.6
    Clone typeType 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
    return sock;
    Preondition Violations
    Unmatched return sock;
    3
    return sock;
    3
    return tcpServer;
    3
    return tcpServer;
    Preondition Violations
    Unmatched return tcpServer;
                                            
    Precondition Violations (2)
    Row Violation
    1Unmatched return sock;
    2Unmatched return tcpServer;