if (c.getType().equals(IComponent.TYPE.EVENT)) { IEvent event = (IEvent) c; Calendar startDate = event.getDtStart(); Calendar endDate = event.getDtEnd(); IDateRange dr = new DateRange(startDate, endDate); if (dateRange.equals(dr)) result.add(id); } else if (c.getType().equals(IComponent.TYPE.TODO)) { ITodo todo = (ITodo) c; Calendar startDate = todo.getDtStart(); Calendar endDate = todo.getDue(); IDateRange dr = new DateRange(startDate, endDate); if (dateRange.equals(dr)) result.add(id); } else throw new IllegalArgumentException( "unsupported component type " + c.getType());
String id = it.next(); IComponentInfo c = get(id); if (c.getType().equals(IComponent.TYPE.EVENT)) { IEvent event = (IEvent) c; Calendar sd = event.getDtStart(); if (startDate.equals(sd)) result.add(id); } else if (c.getType().equals(IComponent.TYPE.TODO)) { ITodo todo = (ITodo) c; Calendar sd = todo.getDtStart(); Calendar endDate = todo.getDue(); IDateRange dr = new DateRange(startDate, endDate); if (startDate.equals(sd)) result.add(id); } else throw new IllegalArgumentException( "unsupported component type " + c.getType());
Clone fragments detected by clone detection tool
File path: /columba-1.4-src/calendar/src/main/java/org/columba/calendar/store/LocalCalendarStore.java File path: /columba-1.4-src/calendar/src/main/java/org/columba/calendar/store/LocalCalendarStore.java
Method name: Iterator findByDateRange(IDateRange) Method name: Iterator findByStartDate(Calendar)
Number of AST nodes: 15 Number of AST nodes: 15
1
String id = it.next();
2
			IComponentInfo c = get(id);
1
if (c.getType().equals(IComponent.TYPE.EVENT)) {
3
			if (c.getType().equals(IComponent.TYPE.EVENT)) {
2
				IEvent event = (IEvent) c;
4
				IEvent event = (IEvent) c;
3
				Calendar startDate = event.getDtStart();
5
				Calendar sd = event.getDtStart();
4
				Calendar endDate = event.getDtEnd();
6
				
5
				IDateRange dr = new DateRange(startDate, endDate);
6
				if (dateRange.equals(dr))
7
if (startDate.equals(sd))
7
					result.add(id);
8
					result.add(id);
8
			} else if (c.getType().equals(IComponent.TYPE.TODO)) {
9
			} else if (c.getType().equals(IComponent.TYPE.TODO)) {
9
				ITodo todo = (ITodo) c;
10
				ITodo todo = (ITodo) c;
10
				Calendar startDate = todo.getDtStart();
11
				Calendar sd = todo.getDtStart();
11
				Calendar endDate = todo.getDue();
12
				Calendar endDate = todo.getDue();
12
				IDateRange dr = new DateRange(startDate, endDate);
13
				IDateRange dr = new DateRange(startDate, endDate);
13
				if (dateRange.equals(dr))
14
				if (startDate.equals(sd))
14
					result.add(id);
15
					result.add(id);
15
			} else
16
			} else
16
				throw new IllegalArgumentException(
17
				throw new IllegalArgumentException(
17
						"unsupported component type " + c.getType());
18
						"unsupported component type " + c.getType());
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)1.3
Clones locationClones are declared in the same class
Number of node comparisons67
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements13
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)6.5
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                  
    4
    String id = it.next();
    Preondition Violations
    Unmatched statement String id=it.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    String id = it.next();
                                                            
    5
    IComponentInfo c = get(id);
    Preondition Violations
    Unmatched statement IComponentInfo c=get(id); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    IComponentInfo c = get(id);
    6
    if (c.getType().equals(IComponent.TYPE.EVENT))
    6
    if (c.getType().equals(IComponent.TYPE.EVENT))
    7
    IEvent event = (IEvent)c;
    7
    IEvent event = (IEvent)c;
    8
    Calendar startDate = event.getDtStart();
    8
    Calendar startDate = event.getDtStart();
    8
    Calendar sd = event.getDtStart();
    Differences
    Expression1Expression2Difference
    startDatesdVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression startDate cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression sd cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8
    Calendar sd = event.getDtStart();
    9
    Calendar endDate = event.getDtEnd();
    9
    Calendar endDate = event.getDtEnd();
    Preondition Violations
    Unmatched statement Calendar endDate=event.getDtEnd(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                              
    10
    IDateRange dr = new DateRange(startDate, endDate);
    10
    IDateRange dr = new DateRange(startDate, endDate);
    Preondition Violations
    Unmatched statement IDateRange dr=new DateRange(startDate,endDate); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                          
    11
    if (dateRange.equals(dr))
    11
    if (dateRange.equals(dr))
    9
    if (startDate.equals(sd))
    Differences
    Expression1Expression2Difference
    drsdVARIABLE_NAME_MISMATCH
    org.columba.calendar.model.api.IDateRangejava.util.CalendarVARIABLE_TYPE_MISMATCH
    dateRangestartDateVARIABLE_NAME_MISMATCH
    org.columba.calendar.model.api.IDateRangejava.util.CalendarVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression dr cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression sd cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.columba.calendar.model.api.IDateRange of variable dr does not match with type java.util.Calendar of variable sd
    • Make classes org.columba.calendar.model.api.IDateRange and java.util.Calendar extend a common superclass
    Type org.columba.calendar.model.api.IDateRange of variable dateRange does not match with type java.util.Calendar of variable startDate
    • Make classes org.columba.calendar.model.api.IDateRange and java.util.Calendar extend a common superclass
    9
    if (startDate.equals(sd))
    12
    result.add(id);
    10
    result.add(id);
    13
    else if (c.getType().equals(IComponent.TYPE.TODO))
    11
    else if (c.getType().equals(IComponent.TYPE.TODO))
    14
    ITodo todo = (ITodo)c;
    12
    ITodo todo = (ITodo)c;
    15
    Calendar startDate = todo.getDtStart();
    15
    Calendar startDate = todo.getDtStart();
    13
    Calendar sd = todo.getDtStart();
    Differences
    Expression1Expression2Difference
    startDatesdVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression startDate cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression sd cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13
    Calendar sd = todo.getDtStart();
    16
    Calendar endDate = todo.getDue();
    14
    Calendar endDate = todo.getDue();
    17
    IDateRange dr = new DateRange(startDate, endDate);
    15
    IDateRange dr = new DateRange(startDate, endDate);
    18
    if (dateRange.equals(dr))
    18
    if (dateRange.equals(dr))
    16
    if (startDate.equals(sd))
    Differences
    Expression1Expression2Difference
    drsdVARIABLE_NAME_MISMATCH
    org.columba.calendar.model.api.IDateRangejava.util.CalendarVARIABLE_TYPE_MISMATCH
    dateRangestartDateVARIABLE_NAME_MISMATCH
    org.columba.calendar.model.api.IDateRangejava.util.CalendarVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression dr cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression sd cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.columba.calendar.model.api.IDateRange of variable dr does not match with type java.util.Calendar of variable sd
    • Make classes org.columba.calendar.model.api.IDateRange and java.util.Calendar extend a common superclass
    Type org.columba.calendar.model.api.IDateRange of variable dateRange does not match with type java.util.Calendar of variable startDate
    • Make classes org.columba.calendar.model.api.IDateRange and java.util.Calendar extend a common superclass
    16
    if (startDate.equals(sd))
    19
    result.add(id);
    17
    result.add(id);
    else
    else
    20
    throw new IllegalArgumentException("unsupported component type " + c.getType());
    18
    throw new IllegalArgumentException("unsupported component type " + c.getType());
    Precondition Violations (17)
    Row Violation
    1Unmatched statement String id=it.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement IComponentInfo c=get(id); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Expression startDate cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression sd cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Unmatched statement Calendar endDate=event.getDtEnd(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement IDateRange dr=new DateRange(startDate,endDate); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Expression dr cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression sd cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Type org.columba.calendar.model.api.IDateRange of variable dr does not match with type java.util.Calendar of variable sd
    10Type org.columba.calendar.model.api.IDateRange of variable dateRange does not match with type java.util.Calendar of variable startDate
    11Expression startDate cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression sd cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression dr cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression sd cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Type org.columba.calendar.model.api.IDateRange of variable dr does not match with type java.util.Calendar of variable sd
    16Type org.columba.calendar.model.api.IDateRange of variable dateRange does not match with type java.util.Calendar of variable startDate
    17Clone fragment #1 returns variables event, startDate , while Clone fragment #2 returns variables