if (other instanceof RubyFixnum || other instanceof RubyBignum) { return f_addsub(context, num, den, other, RubyFixnum.one(context.getRuntime()), true); } else if (other instanceof RubyFloat) { return f_add(context, f_to_f(context, this), other); } else if (other instanceof RubyRational) { RubyRational otherRational = (RubyRational)other; return f_addsub(context, num, den, otherRational.num, otherRational.den, true); } return coerceBin(context, "+", other);
if (other instanceof RubyFixnum || other instanceof RubyBignum) { return f_muldiv(context, num, den, other, RubyFixnum.one(context.getRuntime()), true); } else if (other instanceof RubyFloat) { return f_mul(context, f_to_f(context, this), other); } else if (other instanceof RubyRational) { RubyRational otherRational = (RubyRational)other; return f_muldiv(context, num, den, otherRational.num, otherRational.den, true); } return coerceBin(context, "*", other);
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyRational.java File path: /jruby-1.4.0/src/org/jruby/RubyRational.java
Method name: IRubyObject op_add(ThreadContext, IRubyObject) Method name: IRubyObject op_mul(ThreadContext, IRubyObject)
Number of AST nodes: 8 Number of AST nodes: 8
1
if (other instanceof RubyFixnum || other instanceof RubyBignum) {
1
if (other instanceof RubyFixnum || other instanceof RubyBignum) {
2
            return f_addsub(context, num, den, other, RubyFixnum.one(context.getRuntime()), true);
2
            return f_muldiv(context, num, den, other, RubyFixnum.one(context.getRuntime()), true);
3
        } else if (other instanceof RubyFloat) {
3
        } else if (other instanceof RubyFloat) {
4
            return f_add(context, f_to_f(context, this), other);
4
            return f_mul(context, f_to_f(context, this), other);
5
        } else if (other instanceof RubyRational) {
5
        } else if (other instanceof RubyRational) {
6
            RubyRational otherRational = (RubyRational)other;
6
            RubyRational otherRational = (RubyRational)other;
7
            return f_addsub(context, num, den, otherRational.num, otherRational.den, true);
7
            return f_muldiv(context, num, den, otherRational.num, otherRational.den, true);
8
        }            
8
        }
9
        return coerceBin(context, "+", other);
9
        return coerceBin(context, "*", other);
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.4
Clones locationClones are declared in the same class
Number of node comparisons37
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)61.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (other instanceof RubyFixnum || other instanceof RubyBignum)
    1
    if (other instanceof RubyFixnum || other instanceof RubyBignum)
    2
    return f_addsub(context, num, den, other, RubyFixnum.one(context.getRuntime()), true);
    2
    return f_addsub(context, num, den, other, RubyFixnum.one(context.getRuntime()), true);
    2
    return f_muldiv(context, num, den, other, RubyFixnum.one(context.getRuntime()), true);
    Differences
    Expression1Expression2Difference
    f_addsubf_muldivMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression f_addsub(context,num,den,other,RubyFixnum.one(context.getRuntime()),true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method f_addsub
    Expression f_muldiv(context,num,den,other,RubyFixnum.one(context.getRuntime()),true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method f_muldiv
    2
    return f_muldiv(context, num, den, other, RubyFixnum.one(context.getRuntime()), true);
    3
    else if (other instanceof RubyFloat)
    3
    else if (other instanceof RubyFloat)
    4
    return f_add(context, f_to_f(context, this), other);
    4
    return f_add(context, f_to_f(context, this), other);
    4
    return f_mul(context, f_to_f(context, this), other);
    Differences
    Expression1Expression2Difference
    f_addf_mulMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression f_add(context,f_to_f(context,this),other) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression f_mul(context,f_to_f(context,this),other) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4
    return f_mul(context, f_to_f(context, this), other);
    5
    else if (other instanceof RubyRational)
    5
    else if (other instanceof RubyRational)
    6
    RubyRational otherRational = (RubyRational)other;
    6
    RubyRational otherRational = (RubyRational)other;
    7
    return f_addsub(context, num, den, otherRational.num, otherRational.den, true);
    7
    return f_addsub(context, num, den, otherRational.num, otherRational.den, true);
    7
    return f_muldiv(context, num, den, otherRational.num, otherRational.den, true);
    Differences
    Expression1Expression2Difference
    f_addsubf_muldivMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression f_addsub(context,num,den,otherRational.num,otherRational.den,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method f_addsub
    Expression f_muldiv(context,num,den,otherRational.num,otherRational.den,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method f_muldiv
    7
    return f_muldiv(context, num, den, otherRational.num, otherRational.den, true);
    8
    return coerceBin(context, "+", other);
    8
    return coerceBin(context, "+", other);
    8
    return coerceBin(context, "*", other);
    Differences
    Expression1Expression2Difference
    "+""*"LITERAL_VALUE_MISMATCH
    8
    return coerceBin(context, "*", other);
    Precondition Violations (6)
    Row Violation
    1Expression f_addsub(context,num,den,other,RubyFixnum.one(context.getRuntime()),true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression f_muldiv(context,num,den,other,RubyFixnum.one(context.getRuntime()),true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression f_add(context,f_to_f(context,this),other) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression f_mul(context,f_to_f(context,this),other) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression f_addsub(context,num,den,otherRational.num,otherRational.den,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression f_muldiv(context,num,den,otherRational.num,otherRational.den,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted