1118-1-2

double total = 0.0; int rowCount = data.getRowCount(); for (int r = 0; r < rowCount; r++) { Number n = data.getValue(r, column); if (n != null) { total += n.doubleValue(); } } return total;
double total = 0.0; int columnCount = data.getColumnCount(); for (int c = 0; c < columnCount; c++) { Number n = data.getValue(row, c); if (n != null) { total += n.doubleValue(); } } return total;

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/data/DataUtilities.java |  | File path: /jfreechart-1.0.10/src/org/jfree/data/DataUtilities.java
Method name: `double calculateColumnTotal(Values2D, int)` |  | Method name: `double calculateRowTotal(Values2D, int)`
Number of AST nodes: 7 |  | Number of AST nodes: 7

1

    double total = 0.0;↵

1

    double total = 0.0;↵

2

            int rowCount = data.getRowCount();↵

2

            int columnCount = data.getColumnCount();↵

3

            for (int r = 0; r < rowCount; r++) {↵

3

            for (int c = 0; c < columnCount; c++) {↵

4

                Number n = data.getValue(r, column);↵

4

                Number n = data.getValue(row, c);↵

5

                if (n != null) {↵

5

                if (n != null) {↵

6

                    total += n.doubleValue();   ↵

6

                    total += n.doubleValue();   ↵

7

                }↵

7

                }↵

8

            }↵

8

            }↵

9

            return total;

9

            return total;

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

1. {Non-refactorable}

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

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

   1

       double total = 0.0;

   1

       double total = 0.0;

   2

       int rowCount = data.getRowCount();

   2 | int rowCount = data.getRowCount();
   2 | int columnCount = data.getColumnCount();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   rowCount | columnCount | VARIABLE_NAME_MISMATCH
   getRowCount | getColumnCount | METHOD_INVOCATION_NAME_MISMATCH

   2

       int columnCount = data.getColumnCount();

   3

       for (int r = 0; r < rowCount; r++)

   3 | for (int r = 0; r < rowCount; r++)
   3 | for (int c = 0; c < columnCount; c++)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r | c | VARIABLE_NAME_MISMATCH
   r | c | VARIABLE_NAME_MISMATCH
   rowCount | columnCount | VARIABLE_NAME_MISMATCH
   r | c | VARIABLE_NAME_MISMATCH

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

   3

       for (int c = 0; c < columnCount; c++)

   4

       Number n = data.getValue(r, column);

   4 | Number n = data.getValue(r, column);
   4 | Number n = data.getValue(row, c);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r | row | VARIABLE_NAME_MISMATCH
   column | c | VARIABLE_NAME_MISMATCH

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

   4

       Number n = data.getValue(row, c);

   5

       if (n != null)

   5

       if (n != null)

   6

       total += n.doubleValue();

   6

       total += n.doubleValue();

   7

       return total;

   7

       return total;

   Precondition Violations (4)
   Row | Violation
   --- | ---
   1 | Expression r cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression c cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Expression r cannot be parameterized, because it has dependencies to/from statements that will be extracted
   4 | Expression c cannot be parameterized, because it has dependencies to/from statements that will be extracted