float width = 0.0F; int percIndex = widthStr.indexOf('%'); if (percIndex > 0) { width = Float.parseFloat(widthStr.substring(0, percIndex)); xPercent = true; return width / HUNDRED; } else { xPercent = false; return Float.parseFloat(widthStr); }
int percIndex = heightStr.indexOf('%'); if (percIndex > 0) { float height = Float.parseFloat(heightStr.substring(0, percIndex)); yPercent = true; return height / HUNDRED; } else { yPercent = false; return Float.parseFloat(heightStr); }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/types/optional/image/Scale.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/types/optional/image/Scale.java
Method name: float getWidth() Method name: float getHeight()
Number of AST nodes: 8 Number of AST nodes: 7
1
float width = 0.0F;
2
        int percIndex = widthStr.indexOf('%');
1
int percIndex = heightStr.indexOf('%');
3
        if (percIndex > 0) {
2
        if (percIndex > 0) {
4
            width = Float.parseFloat(widthStr.substring(0, percIndex));
3
            float height = Float.parseFloat(heightStr.substring(0, percIndex));
5
            xPercent = true;
4
            yPercent = true;
6
            return width / HUNDRED;
5
            return height / HUNDRED;
7
        } else {
6
        } else {
8
            xPercent = false;
7
            yPercent = false;
9
            return Float.parseFloat(widthStr);
8
            return Float.parseFloat(heightStr);
10
        }
9
        }
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.1
Clones locationClones are declared in the same class
Number of node comparisons38
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.3
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    float width = 0.0F;
                                            
    2
    int percIndex = widthStr.indexOf('%');
    2
    int percIndex = widthStr.indexOf('%');
    1
    int percIndex = heightStr.indexOf('%');
    Differences
    Expression1Expression2Difference
    widthStrheightStrVARIABLE_NAME_MISMATCH
    1
    int percIndex = heightStr.indexOf('%');
    3
    if (percIndex > 0)
    2
    if (percIndex > 0)
                                                                                                                                          
    3
    float height = Float.parseFloat(heightStr.substring(0, percIndex));
    Preondition Violations
    Unmatched statement float height=Float.parseFloat(heightStr.substring(0,percIndex)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    float height = Float.parseFloat(heightStr.substring(0, percIndex));
    4
    width = Float.parseFloat(widthStr.substring(0, percIndex));
    4
    width = Float.parseFloat(widthStr.substring(0, percIndex));
    Preondition Violations
    Unmatched statement width=Float.parseFloat(widthStr.substring(0,percIndex)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                          
    5
    xPercent = true;
    5
    xPercent = true;
    4
    yPercent = true;
    Differences
    Expression1Expression2Difference
    xPercentyPercentVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression xPercent is a field being modified, and thus it cannot be parameterized
    Expression yPercent is a field being modified, and thus it cannot be parameterized
    4
    yPercent = true;
    6
    return width / HUNDRED;
    6
    return width / HUNDRED;
    5
    return height / HUNDRED;
    Differences
    Expression1Expression2Difference
    widthheightVARIABLE_NAME_MISMATCH
    5
    return height / HUNDRED;
    else
    else
    7
    xPercent = false;
    7
    xPercent = false;
    6
    yPercent = false;
    Differences
    Expression1Expression2Difference
    xPercentyPercentVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression xPercent is a field being modified, and thus it cannot be parameterized
    Expression yPercent is a field being modified, and thus it cannot be parameterized
    6
    yPercent = false;
    8
    return Float.parseFloat(widthStr);
    8
    return Float.parseFloat(widthStr);
    7
    return Float.parseFloat(heightStr);
    Differences
    Expression1Expression2Difference
    widthStrheightStrVARIABLE_NAME_MISMATCH
    7
    return Float.parseFloat(heightStr);
    Precondition Violations (6)
    Row Violation
    1Unmatched statement float height=Float.parseFloat(heightStr.substring(0,percIndex)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement width=Float.parseFloat(widthStr.substring(0,percIndex)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Expression xPercent is a field being modified, and thus it cannot be parameterized
    4Expression yPercent is a field being modified, and thus it cannot be parameterized
    5Expression xPercent is a field being modified, and thus it cannot be parameterized
    6Expression yPercent is a field being modified, and thus it cannot be parameterized