if(o instanceof RubyString) { String str = o.asJavaString(); double d = RubyNumeric.num2dbl(o.convertToFloat()); if(str.matches("^\\s*[-+]?\\s*[0-9].*")) { return d; } else { throw runtime.newTypeError("array item not a float"); } } return RubyKernel.new_float(o, o).getDoubleValue();
if(o instanceof RubyString) { String str = o.asJavaString(); float f = (float)RubyNumeric.num2dbl(o.convertToFloat()); if(str.matches("^\\s*[-+]?\\s*[0-9].*")) { return f; } else { throw runtime.newTypeError("array item not a float"); } } return (float)RubyKernel.new_float(o, o).getDoubleValue();
Clone fragments detected by clone detection tool
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();
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.3
Clones locationClones are declared in the same class
Number of node comparisons19
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)0.9
    Clone typeType 2
    Mapped Statements
    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());
    Preondition Violations
    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
    3
    float f = (float)RubyNumeric.num2dbl(o.convertToFloat());
    3
    double d = RubyNumeric.num2dbl(o.convertToFloat());
    3
    double d = RubyNumeric.num2dbl(o.convertToFloat());
    Preondition Violations
    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
                                                                                                            
    4
    if (str.matches("^\\s*[-+]?\\s*[0-9].*"))
    4
    if (str.matches("^\\s*[-+]?\\s*[0-9].*"))
                            
    5
    return f;
    Preondition Violations
    Unmatched return f;
    5
    return f;
    5
    return d;
    5
    return d;
    Preondition Violations
    Unmatched 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();
    Preondition Violations
    Unmatched return (float)RubyKernel.new_float(o,o).getDoubleValue();
    7
    return (float)RubyKernel.new_float(o, o).getDoubleValue();
    7
    return RubyKernel.new_float(o, o).getDoubleValue();
    7
    return RubyKernel.new_float(o, o).getDoubleValue();
    Preondition Violations
    Unmatched return RubyKernel.new_float(o,o).getDoubleValue();
                                                                                                              
    Precondition Violations (6)
    Row Violation
    1Unmatched 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
    2Unmatched 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
    3Unmatched return f;
    4Unmatched return d;
    5Unmatched return (float)RubyKernel.new_float(o,o).getDoubleValue();
    6Unmatched return RubyKernel.new_float(o,o).getDoubleValue();