285-1-2

Second result = null; if (this.second != LAST_SECOND_IN_MINUTE) { result = new Second(this.second + 1, getMinute()); } else { Minute next = (Minute) getMinute().next(); if (next != null) { result = new Second(FIRST_SECOND_IN_MINUTE, next); } } return result;
Second result = null; if (this.second != FIRST_SECOND_IN_MINUTE) { result = new Second(this.second - 1, getMinute()); } else { Minute previous = (Minute) getMinute().previous(); if (previous != null) { result = new Second(LAST_SECOND_IN_MINUTE, previous); } } return result;

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/data/time/Second.java |  | File path: /jfreechart-1.0.10/src/org/jfree/data/time/Second.java
Method name: `RegularTimePeriod next()` |  | Method name: `RegularTimePeriod previous()`
Number of AST nodes: 7 |  | Number of AST nodes: 7

1

    Second result = null;↵

1

    Second result = null;↵

2

            if (this.second != LAST_SECOND_IN_MINUTE) {↵

2

            if (this.second != FIRST_SECOND_IN_MINUTE) {↵

3

                result = new Second(this.second + 1, getMinute());↵

3

                result = new Second(this.second - 1, getMinute());↵

4

            }↵

4

            }↵

5

            else {↵

5

            else {↵

6

                Minute next = (Minute) getMinute().next();↵

6

                Minute previous = (Minute) getMinute().previous();↵

7

                if (next != null) {↵

7

                if (previous != null) {↵

8

                    result = new Second(FIRST_SECOND_IN_MINUTE, next);↵

8

                    result = new Second(LAST_SECOND_IN_MINUTE, previous);↵

9

                }↵

9

                }↵

10

            }↵

10

            }↵

11

            return result;

11

            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 | 17

1. {Non-refactorable}

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

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

   1

       Second result = null;

   1

       Second result = null;

   2

       if (this.second != LAST_SECOND_IN_MINUTE)

   2 | if (this.second != LAST_SECOND_IN_MINUTE)
   2 | if (this.second != FIRST_SECOND_IN_MINUTE)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   LAST_SECOND_IN_MINUTE | FIRST_SECOND_IN_MINUTE | VARIABLE_NAME_MISMATCH

   2

       if (this.second != FIRST_SECOND_IN_MINUTE)

   3 | result = new Second(this.second - 1, getMinute());

   Preondition Violations
   Unmatched statement result=new Second(this.second - 1,getMinute()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   3

       result = new Second(this.second - 1, getMinute());

   3

       result = new Second(this.second + 1, getMinute());

   3 | result = new Second(this.second + 1, getMinute());

   Preondition Violations
   Unmatched statement result=new Second(this.second + 1,getMinute()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

       else

       else

   4

       Minute next = (Minute)getMinute().next();

   4 | Minute next = (Minute)getMinute().next();
   4 | Minute previous = (Minute)getMinute().previous();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   next | previous | VARIABLE_NAME_MISMATCH
   next | previous | METHOD_INVOCATION_NAME_MISMATCH

   4

       Minute previous = (Minute)getMinute().previous();

   5

       if (next != null)

   5 | if (next != null)
   5 | if (previous != null)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   next | previous | VARIABLE_NAME_MISMATCH

   5

       if (previous != null)

   6

       result = new Second(FIRST_SECOND_IN_MINUTE, next);

   6 | result = new Second(FIRST_SECOND_IN_MINUTE, next);
   6 | result = new Second(LAST_SECOND_IN_MINUTE, previous);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   FIRST_SECOND_IN_MINUTE | LAST_SECOND_IN_MINUTE | VARIABLE_NAME_MISMATCH
   next | previous | VARIABLE_NAME_MISMATCH

   6

       result = new Second(LAST_SECOND_IN_MINUTE, previous);

   7

       return result;

   7

       return result;

   Precondition Violations (2)
   Row | Violation
   --- | ---
   1 | Unmatched statement result=new Second(this.second - 1,getMinute()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   2 | Unmatched statement result=new Second(this.second + 1,getMinute()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted