year = Month.evaluateAsYear(s2); if (year != null) { month = SerialDate.stringToMonthCode(s1); if (month == -1) { throw new TimePeriodFormatException( "Can't evaluate the month." ); } result = new Month(month, year); } else { throw new TimePeriodFormatException( "Can't evaluate the year." ); }
y = Week.evaluateAsYear(s2); if (y != null) { w = Week.stringToWeek(s1); if (w == -1) { throw new TimePeriodFormatException( "Can't evaluate the week."); } result = new Week(w, y); } else { throw new TimePeriodFormatException( "Can't evaluate the year."); }
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/data/time/Month.java File path: /jfreechart-1.0.10/src/org/jfree/data/time/Week.java
Method name: Month parseMonth(String) Method name: Week parseWeek(String)
Number of AST nodes: 7 Number of AST nodes: 7
1
year = Month.evaluateAsYear(s2);
1
y = Week.evaluateAsYear(s2);
2
                    if (year != null) {
2
                    if (y != null) {
3
                        month = SerialDate.stringToMonthCode(s1);
3
                        w = Week.stringToWeek(s1);
4
                        if (month == -1) {
4
                        if (w == -1) {
5
                            throw new TimePeriodFormatException(
5
                            throw new TimePeriodFormatException(
6
                                "Can't evaluate the month."
6
                                    "Can't evaluate the 
7
                            );
7
week.");
8
                        }
8
                        }
9
                        result = new Month(month, year);
9
                        result = new Week(w, y);
10
                    }
10
                    }
11
                    else {
11
                    else {
12
                        throw new TimePeriodFormatException(
12
                        throw new TimePeriodFormatException(
13
                            "Can't evaluate the year."
13
                                "Can't evaluate the year."
14
                        );
14
);
15
                    }
15
                    }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.3
Clones locationClones are in different classes having the same super class
Number of node comparisons23
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    15
    year = Month.evaluateAsYear(s2);
    15
    year = Month.evaluateAsYear(s2);
    15
    y = Week.evaluateAsYear(s2);
    Differences
    Expression1Expression2Difference
    yearyVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.WeekSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression Month cannot be unified with expression Week , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) private static org.jfree.data.time.Year evaluateAsYear(java.lang.String)
    15
    y = Week.evaluateAsYear(s2);
    16
    if (year != null)
    16
    if (year != null)
    16
    if (y != null)
    Differences
    Expression1Expression2Difference
    yearyVARIABLE_NAME_MISMATCH
    16
    if (y != null)
                                                            
    17
    w = Week.stringToWeek(s1);
    17
    month = SerialDate.stringToMonthCode(s1);
                                                                                          
    18
    if (month == -1)
    18
    if (month == -1)
    18
    if (w == -1)
    Differences
    Expression1Expression2Difference
    monthwVARIABLE_NAME_MISMATCH
    18
    if (w == -1)
    19
    throw new TimePeriodFormatException("Can't evaluate the month.");
    19
    throw new TimePeriodFormatException("Can't evaluate the month.");
    19
    throw new TimePeriodFormatException("Can't evaluate the week.");
    Differences
    Expression1Expression2Difference
    "Can't evaluate the month.""Can't evaluate the week."LITERAL_VALUE_MISMATCH
    19
    throw new TimePeriodFormatException("Can't evaluate the week.");
    20
    result = new Month(month, year);
    20
    result = new Month(month, year);
    20
    result = new Week(w, y);
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.Monthorg.jfree.data.time.WeekSUBCLASS_TYPE_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.WeekSUBCLASS_TYPE_MISMATCH
    monthwVARIABLE_NAME_MISMATCH
    yearyVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression new Month(month,year) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new Week(w,y) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20
    result = new Week(w, y);
    else
    else
    21
    throw new TimePeriodFormatException("Can't evaluate the year.");
    21
    throw new TimePeriodFormatException("Can't evaluate the year.");
    Precondition Violations (4)
    Row Violation
    1Expression Month cannot be unified with expression Week , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) private static org.jfree.data.time.Year evaluateAsYear(java.lang.String)
    2Expression new Month(month,year) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression new Week(w,y) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Clone fragment #1 returns variable result with type org.jfree.data.time.Month , while Clone fragment #2 returns variable result with type org.jfree.data.time.Week