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 | } | | | |
See real code fragment |
|
See real code fragment |
-
{Non-refactorable}
Mapping Summary
Number of mapped statements | 3 |
Number of unmapped statements in the first code fragment | 2 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 0.0 |
Similarity Score | 0.500 |
Clone type | Type 3 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
3 | for (TestElement el : getSubControllers()) | | 3 | for (int i = 0; i < SHARE_TAGS.length; i++) |
4 | String name = el.getName(); | | | |
5 | | | 4 | if (SHARE_TAGS[i].equals(mode)) |
6 | | | 5 | |
9 | | | | |
Precondition Violations (5)
Row |
Violation |
1 | Type java.util.List<org.apache.jmeter.testelement.TestElement> of variable getSubControllers() does not match with type java.lang.String[] of variable SHARE_TAGS |
2 | Type java.util.List<org.apache.jmeter.testelement.TestElement> of variable getSubControllers() does not match with type java.lang.String[] of variable SHARE_TAGS |
3 | 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 |
4 | Unmatched statement i++; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
5 | Clone fragment #1 returns variables el , while Clone fragment #2 returns variables |