File path: /jruby-1.4.0/src/org/jruby/util/Pack.java | File path: /jruby-1.4.0/src/org/jruby/util/Pack.java | |||
Method name: double obj2dbl(Ruby, IRubyObject)
|
Method name: float obj2flt(Ruby, IRubyObject)
|
|||
Number of AST nodes: 7 | Number of AST nodes: 7 | |||
1 | if(o instanceof RubyString) {↵ | 1 | if(o instanceof RubyString) {↵ | |
2 | String str = o.asJavaString();↵ | 2 | String str = o.asJavaString();↵ | |
3 | double d = RubyNumeric.num2dbl(o.convertToFloat());↵ | 3 | float f = (float)RubyNumeric.num2dbl(o.convertToFloat());↵ | |
4 | if(str.matches("^\\s*[-+]?\\s*[0-9].*")) {↵ | 4 | if(str.matches("^\\s*[-+]?\\s*[0-9].*")) {↵ | |
5 | return d;↵ | 5 | return f;↵ | |
6 | } else {↵ | 6 | } else {↵ | |
7 | throw runtime.newTypeError("array item not a float");↵ | 7 | throw runtime.newTypeError("array item not a float");↵ | |
8 | }↵ | 8 | }↵ | |
9 | }↵ | 9 | }↵ | |
10 | return RubyKernel.new_float(o, o).getDoubleValue(); | 10 | return (float)RubyKernel.new_float(o, o).getDoubleValue(); | |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.3 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 19 |
Number of mapped statements | 4 |
Number of unmapped statements in the first code fragment | 3 |
Number of unmapped statements in the second code fragment | 3 |
Time elapsed for statement mapping (ms) | 0.9 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||
---|---|---|---|---|---|---|---|
1 | if (o instanceof RubyString) | 1 | if (o instanceof RubyString) | ||||
2 | String str = o.asJavaString(); | 2 | String str = o.asJavaString(); | ||||
|
| 3 | float f = (float)RubyNumeric.num2dbl(o.convertToFloat()); | ||||
3 | double d = RubyNumeric.num2dbl(o.convertToFloat()); |
| | ||||
4 | if (str.matches("^\\s*[-+]?\\s*[0-9].*")) | 4 | if (str.matches("^\\s*[-+]?\\s*[0-9].*")) | ||||
|
| 5 | return f; | ||||
5 | return d; |
| | ||||
else | else | ||||||
6 | throw runtime.newTypeError("array item not a float"); | 6 | throw runtime.newTypeError("array item not a float"); | ||||
|
| 7 | return (float)RubyKernel.new_float(o, o).getDoubleValue(); | ||||
7 | return RubyKernel.new_float(o, o).getDoubleValue(); |
| |
Row | Violation |
---|---|
1 | Unmatched statement float f=(float)RubyNumeric.num2dbl(o.convertToFloat()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
2 | Unmatched statement double d=RubyNumeric.num2dbl(o.convertToFloat()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
3 | Unmatched return f; |
4 | Unmatched return d; |
5 | Unmatched return (float)RubyKernel.new_float(o,o).getDoubleValue(); |
6 | Unmatched return RubyKernel.new_float(o,o).getDoubleValue(); |