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, 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 |
| |
See real code fragment | See real code fragment |
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 |
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.1 |
Clone type | Type 2 |
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, 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; |
Row | Violation |
---|