/** * If there are objects that are not inside a component or a * component-instance the returned vector-set is not null. Then in * the vector-set are the UMLDeploymentDiagram and all FigObjects * with no enclosing FigComponent or FigComponentInstance * * @param dd the diagram to check * @return the set of offenders */ public ListSet computeOffenders(UMLDeploymentDiagram dd) { Collection figs = dd.getLayer().getContents(); ListSet offs = null; for (Object obj : figs) { if (!(obj instanceof FigObject)) { continue; } FigObject fo = (FigObject) obj; Fig enclosing = fo.getEnclosingFig(); if (enclosing == null || (!(Model.getFacade().isAComponent(enclosing.getOwner()) || Model.getFacade().isAComponentInstance( enclosing.getOwner())))) { if (offs == null) { offs = new ListSet(); offs.add(dd); } offs.add(fo); } } return offs; }
/** * If there are interfaces that are not inside a component * the returned ListSet is not null. Then in the ListSet * are the UMLDeploymentDiagram and all FigInterfaces with no * enclosing FigComponent * * @param dd the diagram to check * @return the set of offenders */ public ListSet computeOffenders(UMLDeploymentDiagram dd) { Collection figs = dd.getLayer().getContents(); ListSet offs = null; Iterator figIter = figs.iterator(); while (figIter.hasNext()) { Object obj = figIter.next(); if (!(obj instanceof FigInterface)) { continue; } FigInterface fi = (FigInterface) obj; Fig enclosing = fi.getEnclosingFig(); if (enclosing == null || (!(Model.getFacade() .isAComponent(enclosing.getOwner())))) { if (offs == null) { offs = new ListSet(); offs.add(dd); } offs.add(fi); } } return offs; }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/cognitive/critics/CrObjectWithoutComponent.java File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/cognitive/critics/CrInterfaceWithoutComponent.java
Method name: ListSet computeOffenders(UMLDeploymentDiagram) Method name: ListSet computeOffenders(UMLDeploymentDiagram)
Number of AST nodes: 10 Number of AST nodes: 11
1
/**
1
/**
2
     * If there are objects that are not inside a component or a
2
     * If there are interfaces that are not inside a component
3
     * component-instance the returned vector-set is not null. Then in
3
     * the returned ListSet is not null. Then in the ListSet
4
     * the vector-set are the UMLDeploymentDiagram and all FigObjects
4
     * are the UMLDeploymentDiagram and all FigInterfaces with no
5
     * with no enclosing FigComponent or FigComponentInstance
5
     * enclosing FigComponent
6
     *
6
     *
7
     * @param dd the diagram to check
7
     * @param dd the diagram to check
8
     * @return the set of offenders
8
     * @return the set of offenders
9
     */
9
     */
10
    public ListSet computeOffenders(UMLDeploymentDiagram dd) {
10
    public ListSet computeOffenders(UMLDeploymentDiagram dd) {
11
	Collection figs = dd.getLayer().getContents();
11
	Collection figs = dd.getLayer().getContents();
12
	ListSet offs = null;
12
	ListSet offs = null;
13
        for (Object obj : figs) {
13
        Iterator figIter = figs.iterator();
14
	    if (!(obj instanceof FigObject)) {
14
	while (figIter.hasNext()) {
15
                continue;
15
	    Object obj = figIter.next();
16
            }
16
	    if (!(obj instanceof FigInterface)) {
17
	    FigObject fo = (FigObject) obj;
17
	        continue;
18
	    Fig enclosing = fo.getEnclosingFig();
18
	    }
19
	    if (enclosing == null
19
	    FigInterface fi = (FigInterface) obj;
20
		|| (!(Model.getFacade().isAComponent(enclosing.getOwner())
20
	    Fig enclosing = fi.getEnclosingFig();
21
		|| Model.getFacade().isAComponentInstance(
21
	    if (enclosing == null || (!(Model.getFacade()
22
		        enclosing.getOwner())))) {
22
	            .isAComponent(enclosing.getOwner())))) {
23
		if (offs == null) {
23
		if (offs == null) {
24
		    offs = new ListSet();
24
		    offs = new ListSet();
25
		    offs.add(dd);
25
		    offs.add(dd);
26
		}
26
		}
27
		offs.add(fo);
27
		offs.add(fi);
28
	    }
28
	    }
29
	}
29
	}
30
	return offs;
30
	return offs;
31
    }
31
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements12
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.786
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    3
    for (Object obj : figs)
    4
    while (figIter.hasNext())
                                                              
    5
    Object obj = figIter.next();
    4
    if (!(obj instanceof FigObject))
    4
    if (!(obj instanceof FigObject))
    6
    if (!(obj instanceof FigInterface))
    Differences
    Expression1Expression2Difference
    org.argouml.uml.diagram.deployment.ui.FigObjectorg.argouml.uml.diagram.static_structure.ui.FigInterfaceSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression obj instanceof FigObject cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    if (!(obj instanceof FigInterface))
    5
    continue;
    7
    continue;
    6
    FigObject fo = (FigObject)obj;
    6
    FigObject fo = (FigObject)obj;
    8
    FigInterface fi = (FigInterface)obj;
    Differences
    Expression1Expression2Difference
    org.argouml.uml.diagram.deployment.ui.FigObjectorg.argouml.uml.diagram.static_structure.ui.FigInterfaceSUBCLASS_TYPE_MISMATCH
    fofiVARIABLE_NAME_MISMATCH
    org.argouml.uml.diagram.deployment.ui.FigObjectorg.argouml.uml.diagram.static_structure.ui.FigInterfaceSUBCLASS_TYPE_MISMATCH
    org.argouml.uml.diagram.deployment.ui.FigObjectorg.argouml.uml.diagram.static_structure.ui.FigInterfaceSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (FigObject)obj cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8
    FigInterface fi = (FigInterface)obj;
    7
    Fig enclosing = fo.getEnclosingFig();
    7
    Fig enclosing = fo.getEnclosingFig();
    9
    Fig enclosing = fi.getEnclosingFig();
    Differences
    Expression1Expression2Difference
    fofiVARIABLE_NAME_MISMATCH
    org.argouml.uml.diagram.deployment.ui.FigObjectorg.argouml.uml.diagram.static_structure.ui.FigInterfaceSUBCLASS_TYPE_MISMATCH
    9
    Fig enclosing = fi.getEnclosingFig();
    8
    if (enclosing == null || (!(Model.getFacade().isAComponent(enclosing.getOwner()) || Model.getFacade().isAComponentInstance(enclosing.getOwner()))))
    8
    if (enclosing == null || (!(Model.getFacade().isAComponent(enclosing.getOwner()) || Model.getFacade().isAComponentInstance(enclosing.getOwner()))))
    10
    if (enclosing == null || (!(Model.getFacade().isAComponent(enclosing.getOwner()))))
    Differences
    Expression1Expression2Difference
    Model.getFacade().isAComponent(enclosing.getOwner()) || Model.getFacade().isAComponentInstance(enclosing.getOwner())Model.getFacade().isAComponent(enclosing.getOwner())TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression Model.getFacade().isAComponent(enclosing.getOwner()) || Model.getFacade().isAComponentInstance(enclosing.getOwner()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression Model.getFacade().isAComponent(enclosing.getOwner()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10
    if (enclosing == null || (!(Model.getFacade().isAComponent(enclosing.getOwner()))))
    9
    if (offs == null)
    11
    if (offs == null)
    10
    offs = new ListSet();
    12
    offs = new ListSet();
    11
    offs.add(dd);
    13
    offs.add(dd);
    12
    offs.add(fo);
    12
    offs.add(fo);
    14
    offs.add(fi);
    Differences
    Expression1Expression2Difference
    fofiVARIABLE_NAME_MISMATCH
    org.argouml.uml.diagram.deployment.ui.FigObjectorg.argouml.uml.diagram.static_structure.ui.FigInterfaceSUBCLASS_TYPE_MISMATCH
    14
    offs.add(fi);
    Precondition Violations (4)
    Row Violation
    1Expression obj instanceof FigObject cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression (FigObject)obj cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression Model.getFacade().isAComponent(enclosing.getOwner()) || Model.getFacade().isAComponentInstance(enclosing.getOwner()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression Model.getFacade().isAComponent(enclosing.getOwner()) cannot be parameterized, because it has dependencies to/from statements that will be extracted