if (! (obj instanceof Room)) return false; Room that = (Room) obj; return name.equals(that.name);
if(!(other instanceof RubyHashEntry)) return false; RubyHashEntry otherEntry = (RubyHashEntry)other; return (key == otherEntry.key || key.eql(otherEntry.key)) && (value == otherEntry.value || value.equals(otherEntry.value));
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/test/org/jruby/javasupport/test/Room.java File path: /jruby-1.4.0/src/org/jruby/RubyHash.java
Method name: boolean equals(Object) Method name: boolean equals(Object)
Number of AST nodes: 4 Number of AST nodes: 4
1
if (! (obj instanceof Room))
1
if(!(other instanceof R
2
            return false;
3
            Room that = (Room) obj;
4
            return nam
2
ubyHashEntry)) return false;
3
            RubyHashEntry otherEntry = (RubyHashEntry)other;
4
            
5
            return (key == otherEntry.key || key.eql(otherEntry.key)) &&
5
e.equals(that.name);
6
                    (value == otherEntry.value || value.equals(otherEntry.value));
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.1
Clones locationClones are in different classes
Number of node comparisons8
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    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.8
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (!(obj instanceof Room))
    1
    if (!(obj instanceof Room))
    1
    if (!(other instanceof RubyHashEntry))
    Differences
    Expression1Expression2Difference
    objotherVARIABLE_NAME_MISMATCH
    org.jruby.javasupport.test.Roomorg.jruby.RubyHash.RubyHashEntryVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type boolean of variable obj instanceof Room does not match with type boolean of variable other instanceof RubyHashEntry
    • Make classes org.jruby.javasupport.test.Room and org.jruby.RubyHash.RubyHashEntry extend a common superclass
    1
    if (!(other instanceof RubyHashEntry))
    2
    return false;
    2
    return false;
                                                                                                      
    3
    RubyHashEntry otherEntry = (RubyHashEntry)other;
    3
    Room that = (Room)obj;
                                                  
    4
    return name.equals(that.name);
    4
    return name.equals(that.name);
    4
    return (key == otherEntry.key || key.eql(otherEntry.key)) && (value == otherEntry.value || value.equals(otherEntry.value));
    Differences
    Expression1Expression2Difference
    name.equals(that.name)(key == otherEntry.key || key.eql(otherEntry.key)) && (value == otherEntry.value || value.equals(otherEntry.value))TYPE_COMPATIBLE_REPLACEMENT
    4
    return (key == otherEntry.key || key.eql(otherEntry.key)) && (value == otherEntry.value || value.equals(otherEntry.value));
    Precondition Violations (1)
    Row Violation
    1Type boolean of variable obj instanceof Room does not match with type boolean of variable other instanceof RubyHashEntry