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, false);
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 convertToTypeWithCheck(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, false);↵
|
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;
|
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.4 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 31 |
-
{Refactorable}
Mapping Summary
Number of mapped statements | 8 |
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) | 1.0 |
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 = TypeConverter.convertToType(obj, target, convertMethod, false); | | 3 | IRubyObject val = TypeConverter.convertToType(obj, target, convertMethod, false); |
4 | if (val.isNil()) | | 4 | if (val.isNil()) |
5 | | | 5 | |
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 |