private int scanControllerNames(String sel){ int i = 0; int default_pos = Integer.MAX_VALUE; for(TestElement el : getSubControllers()) { String name=el.getName(); if (name.equals(sel)) { return i; } if (name.equalsIgnoreCase("default")) { //$NON-NLS-1$ default_pos = i; } i++; } return default_pos; }
public static int getShareModeAsInt(String mode) { if (mode == null || mode.length() == 0){ return SHARE_ALL; // default (e.g. if test plan does not have definition) } for (int i = 0; i < SHARE_TAGS.length; i++) { if (SHARE_TAGS[i].equals(mode)) { return i; } } return -1; }
Clone fragments detected by clone detection tool
File path: /apache-jmeter-2.11/src/components/org/apache/jmeter/control/SwitchController.java File path: /apache-jmeter-2.11/src/components/org/apache/jmeter/config/CSVDataSetBeanInfo.java
Method name: int scanControllerNames(String) Method name: int getShareModeAsInt(String)
Number of AST nodes: 7 Number of AST nodes: 3
1
private int scanControllerNames(String sel){
1
public static int getShareModeAsInt(String mode) {
2
        int i = 0;
2
        if (mode == null || mode.length() == 0){
3
        int default_pos = Integer.MAX_VALUE;
3
            return SHARE_ALL; // default (e.g. if test plan does not have definition)
4
        for(TestElement el : getSubControllers()) {
4
        }
5
            String name=el.getName();
5
        for (int i = 0; i < SHARE_TAGS.length; i++) {
6
            if (name.equals(sel)) {
6
            if (SHARE_TAGS[i].equals(mode)) {
7
                return i;
7
                return i;
8
            }
8
            }
9
             if (name.equalsIgnoreCase("default")) {  //$NON-NLS-1$
9
        }
10
                 default_pos = i;
10
        return -1;
11
             }
11
    }
12
            i++;
13
        }
14
        return default_pos;
15
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.500
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    3
    for (TestElement el : getSubControllers())
    3
    for (TestElement el : getSubControllers())
    3
    for (int i = 0; i < SHARE_TAGS.length; i++)
    Differences
    Expression1Expression2Difference
    java.util.Listjava.lang.String[]VARIABLE_TYPE_MISMATCH
    java.util.Listjava.lang.String[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.List<org.apache.jmeter.testelement.TestElement> of variable getSubControllers() does not match with type java.lang.String[] of variable SHARE_TAGS
    • Make classes java.util.List and java.lang.String[] extend a common superclass
    Type java.util.List<org.apache.jmeter.testelement.TestElement> of variable getSubControllers() does not match with type java.lang.String[] of variable SHARE_TAGS
    • Make classes java.util.List and java.lang.String[] extend a common superclass
    3
    for (int i = 0; i < SHARE_TAGS.length; i++)
    4
    String name = el.getName();
    4
    String name = el.getName();
    Preondition Violations
    Unmatched statement String name=el.getName(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                            
    5
    if (name.equals(sel))
    5
    if (name.equals(sel))
    4
    if (SHARE_TAGS[i].equals(mode))
    Differences
    Expression1Expression2Difference
    selmodeVARIABLE_NAME_MISMATCH
    nameSHARE_TAGS[i]TYPE_COMPATIBLE_REPLACEMENT
    4
    if (SHARE_TAGS[i].equals(mode))
    6
    return i;
    5
    return i;
    9
    i++;
    9
    i++;
    Preondition Violations
    Unmatched statement i++; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                  
    Precondition Violations (5)
    Row Violation
    1Type java.util.List<org.apache.jmeter.testelement.TestElement> of variable getSubControllers() does not match with type java.lang.String[] of variable SHARE_TAGS
    2Type java.util.List<org.apache.jmeter.testelement.TestElement> of variable getSubControllers() does not match with type java.lang.String[] of variable SHARE_TAGS
    3Unmatched statement String name=el.getName(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement i++; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Clone fragment #1 returns variables el , while Clone fragment #2 returns variables