if (target.isInstance(obj)) return obj; IRubyObject val = TypeConverter.convertToType(obj, target, convertMethod, false); if (val.isNil()) return val; if (!target.isInstance(val)) throw obj.getRuntime().newTypeError(obj.getMetaClass() + "#" + convertMethod + " should return " + target.getName()); return val;
if (target.isInstance(obj)) return obj; IRubyObject val = TypeConverter.convertToType(obj, target, convertMethod, true); if (val.isNil()) return val; if (!target.isInstance(val)) throw obj.getRuntime().newTypeError(obj.getMetaClass() + "#" + convertMethod + " should return " + target.getName()); return val;
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/util/TypeConverter.java File path: /jruby-1.4.0/src/org/jruby/util/TypeConverter.java
Method name: IRubyObject convertToTypeWithCheck(IRubyObject, RubyClass, int, String) Method name: IRubyObject convertToTypeOrRaise(IRubyObject, RubyClass, String)
Number of AST nodes: 8 Number of AST nodes: 8
1
if (target.isInstance(obj)) return obj;
1
if (target.isInstance(obj)) return obj;
2
        IRubyObject val = TypeConverter.convertToType(obj, target, convertMethod, false);
2
        IRubyObject val = TypeConverter.convertToType(obj, target, convertMethod, true);
3
        if (val.isNil()) return val;
3
        if (val.isNil()) return val;
4
        if (!target.isInstance(val)) throw obj.getRuntime().newTypeError(obj.getMetaClass() + "#" + convertMethod + " should return " + target.getName());
4
        if (!target.isInstance(val)) throw obj.getRuntime().newTypeError(obj.getMetaClass() + "#" + convertMethod + " should return " + target.getName());
5
        return val;
5
        return val;
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.4
Clones locationClones are declared in the same class
Number of node comparisons31
  1. {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)1.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (target.isInstance(obj))
    1
    if (target.isInstance(obj))
    2
    return obj;
    2
    return obj;
    3
    IRubyObject val = TypeConverter.convertToType(obj, target, convertMethod, false);
    3
    IRubyObject val = TypeConverter.convertToType(obj, target, convertMethod, false);
    3
    IRubyObject val = TypeConverter.convertToType(obj, target, convertMethod, true);
    Differences
    Expression1Expression2Difference
    falsetrueLITERAL_VALUE_MISMATCH
    3
    IRubyObject val = TypeConverter.convertToType(obj, target, convertMethod, true);
    4
    if (val.isNil())
    4
    if (val.isNil())
    5
    return val;
    5
    return val;
    6
    if (!target.isInstance(val))
    6
    if (!target.isInstance(val))
    7
    throw obj.getRuntime().newTypeError(obj.getMetaClass() + "#" + convertMethod + " should return " + target.getName());
    7
    throw obj.getRuntime().newTypeError(obj.getMetaClass() + "#" + convertMethod + " should return " + target.getName());
    8
    return val;
    8
    return val;
    Precondition Violations (0)
    Row Violation