if (target.isInstance(obj)) return obj; IRubyObject val = convertToType(obj, target, convertMethod, true); 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 = convertToType(obj, target, convertMethod, true); 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 convertToType(IRubyObject, RubyClass, String) Method name: IRubyObject convertToType(IRubyObject, RubyClass, int, String)
Number of AST nodes: 6 Number of AST nodes: 6
1
if (target.isInstance(obj)) return obj;
1
if (target.isInstance(obj)) return obj;
2
        IRubyObject val = convertToType(obj, target, convertMethod, true);
2
        IRubyObject val = convertToType(obj, target, convertMethod, true);
3
        if (!target.isInstance(val)) throw obj.getRuntime().newTypeError(obj.getMetaClass() + "#" + convertMethod + " should return " + target.getName());
3
        if (!target.isInstance(val)) throw obj.getRuntime().newTypeError(obj.getMetaClass() + "#" + convertMethod + " should return " + target.getName());
4
        return val;
4
        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.2
Clones locationClones are declared in the same class
Number of node comparisons17
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.8
    Clone typeType 1
    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 = convertToType(obj, target, convertMethod, true);
    3
    IRubyObject val = convertToType(obj, target, convertMethod, true);
    4
    if (!target.isInstance(val))
    4
    if (!target.isInstance(val))
    5
    throw obj.getRuntime().newTypeError(obj.getMetaClass() + "#" + convertMethod + " should return " + target.getName());
    5
    throw obj.getRuntime().newTypeError(obj.getMetaClass() + "#" + convertMethod + " should return " + target.getName());
    6
    return val;
    6
    return val;
    Precondition Violations (0)
    Row Violation