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;
|
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 1 |
Number of non-refactorable cases | 0 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.2 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 17 |
-
{Refactorable}
Mapping Summary
Number of mapped statements | 6 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 0.8 |
Clone type | Type 1 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
1 | if (target.isInstance(obj)) | | 1 | if (target.isInstance(obj)) |
2 | | | 2 | |
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 |