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