if (self.respondsTo("write") || self.respondsTo("<<")) { channel = new IOChannel.IOReadableWritableByteChannel(self); } else { channel = new IOChannel.IOReadableByteChannel(self); }
if (self.respondsTo("write") || self.respondsTo("<<")) { channel = new IOChannel.IOWritableByteChannel(self); } else { throw context.getRuntime().newTypeError("object does not respond to any of read, write, or <<"); }
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/java/addons/IOJavaAddons.java File path: /jruby-1.4.0/src/org/jruby/java/addons/IOJavaAddons.java
Method name: IRubyObject any_to_channel(ThreadContext, IRubyObject) Method name: IRubyObject any_to_channel(ThreadContext, IRubyObject)
Number of AST nodes: 3 Number of AST nodes: 3
1
if (self.respondsTo("write") || self.respondsTo("<<")) {
1
if (self.respondsTo("write") || self.respondsTo("<<")) {
2
                    channel = new IOChannel.IOReadableWritableByteChannel(self);
2
                    channel = new IOChannel.IOWritableByteChannel(self);
3
                } else {
3
                } else {
4
                    channel = new IOChannel.IOReadableByteChannel(self);
4
                    throw context.getRuntime().newTypeError("object does not respond to any of read, write, or <<");
5
                }
5
                }
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.3
Clones locationClones are in the same method
Number of node comparisons9
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    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.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    3
    if (self.respondsTo("write") || self.respondsTo("<<"))
    6
    if (self.respondsTo("write") || self.respondsTo("<<"))
    4
    channel = new IOChannel.IOReadableWritableByteChannel(self);
    4
    channel = new IOChannel.IOReadableWritableByteChannel(self);
    7
    channel = new IOChannel.IOWritableByteChannel(self);
    Differences
    Expression1Expression2Difference
    IOReadableWritableByteChannelIOWritableByteChannelVARIABLE_NAME_MISMATCH
    7
    channel = new IOChannel.IOWritableByteChannel(self);
    else
            
    5
    channel = new IOChannel.IOReadableByteChannel(self);
    5
    channel = new IOChannel.IOReadableByteChannel(self);
    Preondition Violations
    Unmatched statement channel=new IOChannel.IOReadableByteChannel(self); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                              
                                                                                                                                                                                                          
    8
    throw context.getRuntime().newTypeError("object does not respond to any of read, write, or <<");
    Preondition Violations
    Unmatched throw context.getRuntime().newTypeError("object does not respond to any of read, write, or <<");
    8
    throw context.getRuntime().newTypeError("object does not respond to any of read, write, or <<");
    Precondition Violations (2)
    Row Violation
    1Unmatched statement channel=new IOChannel.IOReadableByteChannel(self); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched throw context.getRuntime().newTypeError("object does not respond to any of read, write, or <<");