1294-2-3

int result = -1; for (int i = 0; i < this.seriesKeys.length; i++) { if (seriesKey.equals(this.seriesKeys[i])) { result = i; break; } } return result;
int result = -1; for (int i = 0; i < this.categoryKeys.length; i++) { if (category.equals(this.categoryKeys[i])) { result = i; break; } } return result;

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/data/category/DefaultIntervalCategoryDataset.java |  | File path: /jfreechart-1.0.10/src/org/jfree/data/category/DefaultIntervalCategoryDataset.java
Method name: `int getSeriesIndex(Comparable)` |  | Method name: `int getCategoryIndex(Comparable)`
Number of AST nodes: 6 |  | Number of AST nodes: 6

1

    int result = -1;↵

1

    int result = -1;↵

2

            for (int i = 0; i < this.seriesKeys.length; i++) {↵

2

            for (int i = 0; i < this.categoryKeys.length; i++) {↵

3

                if (seriesKey.equals(this.seriesKeys[i])) {↵

3

                if (category.equals(this.categoryKeys[i])) {↵

4

                    result = i;↵

4

                    result = i;↵

5

                    break;↵

5

                    break;↵

6

                }↵

6

                }↵

7

            }↵

7

            }↵

8

            return result;

8

            return result;

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 1
Number of non-refactorable cases | 0
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.3
Clones location | Clones are declared in the same class
Number of node comparisons | 14

1. {Refactorable}

   Mapping Summary
   Number of mapped statements | 6
   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.6
   Clone type | Type 2

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

   1

       int result = -1;

   1

       int result = -1;

   2

       for (int i = 0; i < this.seriesKeys.length; i++)

   2 | for (int i = 0; i < this.seriesKeys.length; i++)
   2 | for (int i = 0; i < this.categoryKeys.length; i++)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   seriesKeys | categoryKeys | VARIABLE_NAME_MISMATCH

   2

       for (int i = 0; i < this.categoryKeys.length; i++)

   3

       if (seriesKey.equals(this.seriesKeys[i]))

   3 | if (seriesKey.equals(this.seriesKeys[i]))
   3 | if (category.equals(this.categoryKeys[i]))

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   seriesKeys | categoryKeys | VARIABLE_NAME_MISMATCH
   seriesKey | category | VARIABLE_NAME_MISMATCH

   3

       if (category.equals(this.categoryKeys[i]))

   4

       result = i;

   4

       result = i;

   5

       break;

   5

       break;

   6

       return result;

   6

       return result;

   Precondition Violations (0)
   Row | Violation
   --- | ---