int beg = RubyNumeric.num2int(this.begin); int end = RubyNumeric.num2int(this.end); if (beg < 0) { beg += len; if (beg < 0) { if (err != 0) throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range"); return null; } } if (err == 0 || err == 2) { if (beg > len) { if (err != 0) throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range"); return null; } if (end > len) end = len; } if (end < 0) end += len; if (!isExclusive) end++; len = end - beg; if (len < 0) len = 0; return new int[]{beg, len};
long beg = RubyNumeric.num2long(this.begin); long end = RubyNumeric.num2long(this.end); if (beg < 0) { beg += len; if (beg < 0) { if (err != 0) throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range"); return null; } } if (err == 0 || err == 2) { if (beg > len) { if (err != 0) throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range"); return null; } if (end > len) end = len; } if (end < 0) end += len; if (!isExclusive) end++; len = end - beg; if (len < 0) len = 0; return new long[]{beg, len};
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyRange.java File path: /jruby-1.4.0/src/org/jruby/RubyRange.java
Method name: int[] begLenInt(int, int) Method name: long[] begLen(long, int)
Number of AST nodes: 23 Number of AST nodes: 23
1
int beg = RubyNumeric.num2int(this.begin);
1
long beg = RubyNumeric.num2long(this.begin);
2
        int end = RubyNumeric.num2int(this.end);
2
        long end = RubyNumeric.num2long(this.end);
3
        if (beg < 0) {
3
        if (beg < 0) {
4
            beg += len;
4
            beg += len;
5
            if (beg < 0) {
5
            if (beg < 0) {
6
                if (err != 0) throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range");
6
                if (err != 0) throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range");
7
                return null;
7
                return null;
8
            }
8
            }
9
        }
9
        }
10
        if (err == 0 || err == 2) {
10
        if (err == 0 || err == 2) {
11
            if (beg > len) {
11
            if (beg > len) {
12
                if (err != 0) throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range");
12
                if (err != 0) throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range");
13
                return null;
13
                return null;
14
            }
14
            }
15
            if (end > len) end = len;
15
            if (end > len) end = len;
16
        }
16
        }
17
        if (end < 0) end += len;
17
        if (end < 0) end += len;
18
        if (!isExclusive) end++;
18
        if (!isExclusive) end++;
19
        len = end - beg;
19
        len = end - beg;
20
        if (len < 0) len = 0;
20
        if (len < 0) len = 0;
21
        return new int[]{beg, len};
21
        return new long[]{beg, len};
Summary
Number of common nesting structure subtrees2
Number of refactorable cases0
Number of non-refactorable cases2
Time elapsed for finding largest common nesting structure subtrees (ms)1.5
Clones locationClones are declared in the same class
Number of node comparisons73
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment14
    Number of unmapped statements in the second code fragment14
    Time elapsed for statement mapping (ms)4.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                              
    1
    long beg = RubyNumeric.num2long(this.begin);
    1
    int beg = RubyNumeric.num2int(this.begin);
                                                                                          
                                                                                          
    2
    long end = RubyNumeric.num2long(this.end);
    2
    int end = RubyNumeric.num2int(this.end);
                                                                                      
    3
    if (beg < 0)
    3
    if (beg < 0)
    3
    if (beg < 0)
    Differences
    Expression1Expression2Difference
    intlongVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type int of variable beg does not match with type long of variable beg
    3
    if (beg < 0)
                            
    4
    beg += len;
    Preondition Violations
    Unmatched statement beg+=len; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    beg += len;
    4
    beg += len;
    4
    beg += len;
    Preondition Violations
    Unmatched statement beg+=len; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                            
    5
    if (beg < 0)
    5
    if (beg < 0)
    5
    if (beg < 0)
    Differences
    Expression1Expression2Difference
    intlongVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type int of variable beg does not match with type long of variable beg
    5
    if (beg < 0)
    6
    if (err != 0)
    6
    if (err != 0)
    7
    throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range");
    7
    throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range");
    7
    throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range");
    Differences
    Expression1Expression2Difference
    intlongVARIABLE_TYPE_MISMATCH
    intlongVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type int of variable end does not match with type long of variable end
    Type int of variable beg does not match with type long of variable beg
    7
    throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range");
    8
    return null;
    8
    return null;
                                                          
    9
    if (err == 0 || err == 2)
                                      
    10
    if (beg > len)
                                    
    11
    if (err != 0)
                                                                                                                                                                                                        
    12
    throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range");
    Preondition Violations
    Unmatched throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "")+ end+ " out of range");
    12
    throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range");
                                    
    13
    return null;
    Preondition Violations
    Unmatched return null;
    13
    return null;
                                      
    14
    if (end > len)
                            
    15
    end = len;
    Preondition Violations
    Unmatched statement end=len; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15
    end = len;
    9
    if (err == 0 || err == 2)
                                                          
    10
    if (beg > len)
                                      
    11
    if (err != 0)
                                    
    12
    throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range");
    12
    throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range");
    Preondition Violations
    Unmatched throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "")+ end+ " out of range");
                                                                                                                                                                                                        
    13
    return null;
    13
    return null;
    Preondition Violations
    Unmatched return null;
                                    
    14
    if (end > len)
                                      
    15
    end = len;
    15
    end = len;
    Preondition Violations
    Unmatched statement end=len; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                            
    16
    if (end < 0)
    16
    if (end < 0)
    16
    if (end < 0)
    Differences
    Expression1Expression2Difference
    intlongVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type int of variable end does not match with type long of variable end
    16
    if (end < 0)
                              
    17
    end += len;
    Preondition Violations
    Unmatched statement end+=len; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17
    end += len;
    17
    end += len;
    17
    end += len;
    Preondition Violations
    Unmatched statement end+=len; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                              
    18
    if (!isExclusive)
    18
    if (!isExclusive)
                        
    19
    end++;
    Preondition Violations
    Unmatched statement end++; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    19
    end++;
    19
    end++;
    19
    end++;
    Preondition Violations
    Unmatched statement end++; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                        
                                        
    20
    len = end - beg;
    20
    len = end - beg;
                                        
    21
    if (len < 0)
    21
    if (len < 0)
    21
    if (len < 0)
    Differences
    Expression1Expression2Difference
    intlongVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type int of variable len does not match with type long of variable len
    21
    if (len < 0)
                        
    22
    len = 0;
    Preondition Violations
    Unmatched statement len=0; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    22
    len = 0;
    22
    len = 0;
    22
    len = 0;
    Preondition Violations
    Unmatched statement len=0; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                        
    Precondition Violations (20)
    Row Violation
    1Type int of variable beg does not match with type long of variable beg
    2Unmatched statement beg+=len; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement beg+=len; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Type int of variable beg does not match with type long of variable beg
    5Type int of variable end does not match with type long of variable end
    6Type int of variable beg does not match with type long of variable beg
    7Unmatched throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "")+ end+ " out of range");
    8Unmatched return null;
    9Unmatched statement end=len; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "")+ end+ " out of range");
    11Unmatched return null;
    12Unmatched statement end=len; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Type int of variable end does not match with type long of variable end
    14Unmatched statement end+=len; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15Unmatched statement end+=len; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16Unmatched statement end++; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17Unmatched statement end++; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    18Type int of variable len does not match with type long of variable len
    19Unmatched statement len=0; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    20Unmatched statement len=0; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
  2. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    11
    if (err != 0)
    6
    if (err != 0)
    12
    throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range");
    12
    throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range");
    7
    throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range");
    Differences
    Expression1Expression2Difference
    intlongVARIABLE_TYPE_MISMATCH
    intlongVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type int of variable end does not match with type long of variable end
    Type int of variable beg does not match with type long of variable beg
    7
    throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range");
    Precondition Violations (2)
    Row Violation
    1Type int of variable end does not match with type long of variable end
    2Type int of variable beg does not match with type long of variable beg