442-1-2

if (values == null) { throw new IllegalArgumentException("Null 'values' argument."); } double result = Double.NaN; int count = values.size(); if (count > 0) { if (count % 2 == 1) { if (count > 1) { result = Statistics.calculateMedian(values, 0, count / 2); } else { result = Statistics.calculateMedian(values, 0, 0); } } else { result = Statistics.calculateMedian(values, 0, count / 2 - 1); } } return result;
if (values == null) { throw new IllegalArgumentException("Null 'values' argument."); } double result = Double.NaN; int count = values.size(); if (count > 0) { if (count % 2 == 1) { if (count > 1) { result = Statistics.calculateMedian(values, count / 2, count - 1); } else { result = Statistics.calculateMedian(values, 0, 0); } } else { result = Statistics.calculateMedian(values, count / 2, count - 1); } } return result;

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/data/statistics/BoxAndWhiskerCalculator.java |  | File path: /jfreechart-1.0.10/src/org/jfree/data/statistics/BoxAndWhiskerCalculator.java
Method name: `double calculateQ1(List)` |  | Method name: `double calculateQ3(List)`
Number of AST nodes: 11 |  | Number of AST nodes: 11

1

    if (values == null) {↵

1

    if (values == null) {↵

2

                throw new IllegalArgumentException("Null 'values' argument.");↵

2

                throw new IllegalArgumentException("Null 'values' argument.");↵

3

            }↵

3

            }↵

4

            ↵

5

            double result = Double.NaN;↵

4

            double result = Double.NaN;↵

6

            int count = values.size();↵

5

            int count = values.size();↵

7

            if (count > 0) {↵

6

            if (count > 0) {↵

8

                if (count % 2 == 1) {↵

7

                if (count % 2 == 1) {↵

9

                    if (count > 1) {↵

8

                    if (count > 1) {↵

10

                        result = Statistics.calculateMedian(values, 0, count / 2↵

9

                        result = Statistics.calculateMedian(values, count / 2, ↵

11

    );↵

10

                                count - 1);↵

12

                    }↵

11

                    }↵

13

                    else {↵

12

                    else {↵

14

                        result = Statistics.calculateMedian(values, 0, 0);↵

13

                        result = Statistics.calculateMedian(values, 0, 0);↵

15

                    }↵

14

                    }↵

16

                }↵

15

                }↵

17

                else {↵

16

                else {↵

18

                    result = Statistics.calculateMedian(values, 0, count / 2 - 1);↵

17

                    result = Statistics.calculateMedian(values, count / 2, ↵

19

                }↵

18

                            count - 1);↵

20

                ↵

19

                }↵

21

            }↵

20

            }↵

22

            return result;

21

            return result;

See real code fragment |  | See real code fragment

Summary
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.2
Clones location | Clones are declared in the same class
Number of node comparisons | 27

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 10
   Number of unmapped statements in the first code fragment | 1
   Number of unmapped statements in the second code fragment | 1
   Time elapsed for statement mapping (ms) | 1.2
   Clone type | Type 2

   Mapped Statements
   ID | Statement |  | ID | Statement
   --- | --- | --- | --- | ---

   1

       if (values == null)

   1

       if (values == null)

   2

       throw new IllegalArgumentException("Null 'values' argument.");

   2

       throw new IllegalArgumentException("Null 'values' argument.");

   3

       double result = Double.NaN;

   3

       double result = Double.NaN;

   4

       int count = values.size();

   4

       int count = values.size();

   5

       if (count > 0)

   5

       if (count > 0)

   6

       if (count % 2 == 1)

   6

       if (count % 2 == 1)

   7

       if (count > 1)

   7

       if (count > 1)

   8 | result = Statistics.calculateMedian(values, count / 2, count - 1);

   Preondition Violations
   Unmatched statement result=Statistics.calculateMedian(values,count / 2,count - 1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   8

       result = Statistics.calculateMedian(values, count / 2, count - 1);

   8

       result = Statistics.calculateMedian(values, 0, count / 2);

   8 | result = Statistics.calculateMedian(values, 0, count / 2);

   Preondition Violations
   Unmatched statement result=Statistics.calculateMedian(values,0,count / 2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

       else

       else

   9

       result = Statistics.calculateMedian(values, 0, 0);

   9

       result = Statistics.calculateMedian(values, 0, 0);

       else

       else

   10

       result = Statistics.calculateMedian(values, 0, count / 2 - 1);

   10 | result = Statistics.calculateMedian(values, 0, count / 2 - 1);
   10 | result = Statistics.calculateMedian(values, count / 2, count - 1);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   0 | count / 2 | TYPE_COMPATIBLE_REPLACEMENT
   count / 2 | count | INFIX_LEFT_OPERAND_MISMATCH

   Preondition Violations
   Expression count / 2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression count / 2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression count cannot be parameterized, because it has dependencies to/from statements that will be extracted

   10

       result = Statistics.calculateMedian(values, count / 2, count - 1);

   11

       return result;

   11

       return result;

   Precondition Violations (6)
   Row | Violation
   --- | ---
   1 | Unmatched statement result=Statistics.calculateMedian(values,count / 2,count - 1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   2 | Unmatched statement result=Statistics.calculateMedian(values,0,count / 2); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   3 | Expression count / 2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
   4 | Expression count / 2 cannot be parameterized, because it has dependencies to/from statements that will be extracted
   5 | Expression count cannot be parameterized, because it has dependencies to/from statements that will be extracted
   6 | Clone fragment #1 returns variables result, count , while Clone fragment #2 returns variables result, count