File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/functions/IntSum.java | File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/functions/LongSum.java | |||
Method name: String execute(SampleResult, Sampler)
|
Method name: String execute(SampleResult, Sampler)
|
|||
Number of AST nodes: 12 | Number of AST nodes: 12 | |||
1 | JMeterVariables vars = getVariables();↵ | 1 | JMeterVariables vars = getVariables();↵ | |
2 | int sum = 0;↵ | 2 | long sum = 0;↵ | |
3 | String varName = ((CompoundVariable) values[values.length - 1]).execute();↵ | 3 | String varName = ((CompoundVariable) values[values.length - 1]).execute().trim();↵ | |
4 | for (int i = 0; i < values.length - 1; i++) {↵ | 4 | for (int i = 0; i < values.length - 1; i++) {↵ | |
5 | sum += Integer.parseInt(((CompoundVariable) values[i]).execute());↵ | 5 | sum += Long.parseLong(((CompoundVariable) values[i]).execute());↵ | |
6 | }↵ | 6 | }↵ | |
7 | try {↵ | 7 | try {↵ | |
8 | sum += Integer.parseInt(varName);↵ | 8 | sum += Long.parseLong(varName);↵ | |
9 | varName = null; // there is no variable name↵ | 9 | varName = null; // there is no variable name↵ | |
10 | } catch (NumberFormatException ignored) {↵ | 10 | } catch (NumberFormatException ignored) {↵ | |
11 | }↵ | 11 | }↵ | |
12 | ↵ | 12 | ↵ | |
13 | String totalString = Integer.toString(sum);↵ | 13 | String totalString = Long.toString(sum);↵ | |
14 | if (vars != null && varName != null){// vars will be null on TestPlan↵ | 14 | if (vars != null && varName != null && varName.length() > 0){// vars will be null on TestPlan↵ | |
15 | vars.put(varName.trim(), totalString);↵ | 15 | vars.put(varName, totalString);↵ | |
16 | }↵ | 16 | }↵ | |
17 | return totalString; | 17 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.7 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 34 |
Number of mapped statements | 4 |
Number of unmapped statements in the first code fragment | 4 |
Number of unmapped statements in the second code fragment | 4 |
Time elapsed for statement mapping (ms) | 1.8 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||
---|---|---|---|---|---|---|---|
1 | JMeterVariables vars = getVariables(); | 1 | JMeterVariables vars = getVariables(); | ||||
| 2 | long sum = 0; | |||||
2 | int sum = 0; | | |||||
| 3 | String varName = ((CompoundVariable)values[values.length - 1]).execute().trim(); | |||||
3 | String varName = ((CompoundVariable)values[values.length - 1]).execute(); | | |||||
4 | for (int i = 0; i < values.length - 1; i++) | 4 | for (int i = 0; i < values.length - 1; i++) | ||||
|
| 5 | sum += Long.parseLong(((CompoundVariable)values[i]).execute()); | ||||
5 | sum += Integer.parseInt(((CompoundVariable)values[i]).execute()); |
| | ||||
6 | try | 6 | try | ||||
|
| 7 | sum += Long.parseLong(varName); | ||||
7 | sum += Integer.parseInt(varName); |
| | ||||
8 | varName = null; | 8 | varName = null; |
Row | Violation |
---|---|
1 | Unmatched statement sum+=Long.parseLong(((CompoundVariable)values[i]).execute()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched statement sum+=Integer.parseInt(((CompoundVariable)values[i]).execute()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Unmatched statement sum+=Long.parseLong(varName); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
4 | Unmatched statement sum+=Integer.parseInt(varName); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
5 | Clone fragment #1 returns variables i, vars, varName , while Clone fragment #2 returns variables i, vars, varName |