String mname = getNewRescueName(); BaseBodyCompiler rescueMethod = outline(mname); rescueMethod.performRescueLight(regularCode, rubyCatchCode, needsRetry); rescueMethod.endBody();
String mname = getNewEnsureName(); BaseBodyCompiler ensure = outline(mname); ensure.performEnsureInner(regularCode, protectedCode);
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/compiler/impl/BaseBodyCompiler.java File path: /jruby-1.4.0/src/org/jruby/compiler/impl/BaseBodyCompiler.java
Method name: void performRescue(BranchCallback, BranchCallback, boolean) Method name: void performEnsure(BranchCallback, BranchCallback)
Number of AST nodes: 4 Number of AST nodes: 3
1
String mname = getNewRescueName();
1
String mname = getNewEnsureName();
2
        BaseBodyCompiler rescueMethod = outline(mname);
2
        BaseBodyCompiler ensure = outline(mname);
3
        rescueMethod.performRescueLight(regularCode, rubyCatchCode, needsRetry);
3
        
4
        rescueMethod.endBody();
4
ensure.performEnsureInner(regularCode, protectedCode);
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.0
Clones locationClones are declared in the same class
Number of node comparisons6
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    String mname = getNewRescueName();
    1
    String mname = getNewRescueName();
    1
    String mname = getNewEnsureName();
    Differences
    Expression1Expression2Difference
    getNewRescueNamegetNewEnsureNameMETHOD_INVOCATION_NAME_MISMATCH
    1
    String mname = getNewEnsureName();
    2
    BaseBodyCompiler rescueMethod = outline(mname);
    2
    BaseBodyCompiler rescueMethod = outline(mname);
    2
    BaseBodyCompiler ensure = outline(mname);
    Differences
    Expression1Expression2Difference
    rescueMethodensureVARIABLE_NAME_MISMATCH
    2
    BaseBodyCompiler ensure = outline(mname);
    3
    rescueMethod.performRescueLight(regularCode, rubyCatchCode, needsRetry);
    3
    rescueMethod.performRescueLight(regularCode, rubyCatchCode, needsRetry);
    Preondition Violations
    Unmatched statement rescueMethod.performRescueLight(regularCode,rubyCatchCode,needsRetry); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                      
    4
    rescueMethod.endBody();
    4
    rescueMethod.endBody();
    3
    ensure.performEnsureInner(regularCode, protectedCode);
    Differences
    Expression1Expression2Difference
    endBodyperformEnsureInnerMETHOD_INVOCATION_NAME_MISMATCH
    rescueMethodensureVARIABLE_NAME_MISMATCH
    rescueMethod.endBody()ensure.performEnsureInner(regularCode,protectedCode)ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression rescueMethod.endBody() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ensure.performEnsureInner(regularCode,protectedCode) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method performEnsureInner
    Expression rescueMethod.endBody() is a void method call, and thus it cannot be parameterized
    Expression ensure.performEnsureInner(regularCode,protectedCode) is a void method call, and thus it cannot be parameterized
    Expression rescueMethod.endBody() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ensure.performEnsureInner(regularCode,protectedCode) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method performEnsureInner
    Expression rescueMethod.endBody() is a void method call, and thus it cannot be parameterized
    Expression ensure.performEnsureInner(regularCode,protectedCode) is a void method call, and thus it cannot be parameterized
    3
    ensure.performEnsureInner(regularCode, protectedCode);
    Precondition Violations (10)
    Row Violation
    1Unmatched statement rescueMethod.performRescueLight(regularCode,rubyCatchCode,needsRetry); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Expression rescueMethod.endBody() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression ensure.performEnsureInner(regularCode,protectedCode) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression rescueMethod.endBody() is a void method call, and thus it cannot be parameterized
    5Expression ensure.performEnsureInner(regularCode,protectedCode) is a void method call, and thus it cannot be parameterized
    6Expression rescueMethod.endBody() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression ensure.performEnsureInner(regularCode,protectedCode) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression rescueMethod.endBody() is a void method call, and thus it cannot be parameterized
    9Expression ensure.performEnsureInner(regularCode,protectedCode) is a void method call, and thus it cannot be parameterized
    10Clone fragment #1 returns variables rescueMethod , while Clone fragment #2 returns variables