/** * If there are component-instances that have no enclosing FigMNodeInstance * the returned ListSet is not null. Then in the ListSet * are the UMLDeploymentDiagram and all FigComponentInstances with no * enclosing FigMNodeInstance * * @param deploymentDiagram the diagram to check * @return the set of offenders */ public ListSet computeOffenders(UMLDeploymentDiagram deploymentDiagram) { Collection figs = deploymentDiagram.getLayer().getContents(); ListSet offs = null; Iterator figIter = figs.iterator(); while (figIter.hasNext()) { Object obj = figIter.next(); if (!(obj instanceof FigComponentInstance)) { continue; } FigComponentInstance figComponentInstance = (FigComponentInstance) obj; if (figComponentInstance != null) { Object coi = figComponentInstance.getOwner(); if (coi != null) { Collection col = Model.getFacade().getClassifiers(coi); if (col.size() > 0) { continue; } } if (offs == null) { offs = new ListSet(); offs.add(deploymentDiagram); } offs.add(figComponentInstance); } } 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; if (fo != null) { Object mobj = fo.getOwner(); if (mobj != null) { Collection col = Model.getFacade().getClassifiers(mobj); if (col.size() > 0) { continue; } } 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/CrComponentInstanceWithoutClassifier.java File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/cognitive/critics/CrObjectWithoutClassifier.java
Method name: ListSet computeOffenders(UMLDeploymentDiagram) Method name: ListSet computeOffenders(UMLDeploymentDiagram)
Number of AST nodes: 15 Number of AST nodes: 14
1
/**
1
/**
2
     * If there are component-instances that have no enclosing FigMNodeInstance
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 FigComponentInstances with no
4
     * the vector-set are the UMLDeploymentDiagram and all FigObjects
5
     * enclosing FigMNodeInstance
5
     * with no enclosing FigComponent or FigComponentInstance
6
     *
6
     *
7
     * @param deploymentDiagram 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 deploymentDiagram) {
10
    public ListSet computeOffenders(UMLDeploymentDiagram dd) {
11
11
	Collection figs = dd.getLayer().getContents();
12
	Collection figs = deploymentDiagram.getLayer().getContents();
12
	ListSet offs = null;
13
        ListSet offs = null;
13
        for (Object obj : figs) {
14
        Iterator figIter = figs.iterator();
14
	    if (!(obj instanceof FigObject)) {
15
	while (figIter.hasNext()) {
15
                continue;
16
	    Object obj = figIter.next();
16
            }
17
	    if (!(obj instanceof FigComponentInstance)) {
17
	    FigObject fo = (FigObject) obj;
18
	        continue;
18
	    if (fo != null) {
19
	    }
19
		Object mobj = fo.getOwner();
20
	    FigComponentInstance figComponentInstance =
20
		if (mobj != null) {
21
	        (FigComponentInstance) obj;
21
		    Collection col = Model.getFacade().getClassifiers(mobj);
22
	    if (figComponentInstance != null) {
22
		    if (col.size() > 0) {
23
		Object coi =
23
		        continue;
24
		    figComponentInstance.getOwner();
24
		    }
25
		if (coi != null) {
25
		}
26
		    Collection col = Model.getFacade().getClassifiers(coi);
26
		if (offs == null) {
27
		    if (col.size() > 0) {
27
		    offs = new ListSet();
28
		        continue;
28
		    offs.add(dd);
29
		    }
29
		}
30
		}
30
		offs.add(fo);
31
		if (offs == null) {
31
	    }
32
		    offs = new ListSet();
32
	}
33
		    offs.add(deploymentDiagram);
33
	return offs;
34
		}
34
    }
35
		offs.add(figComponentInstance);
36
	    }
37
	}
38
39
	return offs;
40
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements16
    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.846
    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 FigComponentInstance))
    6
    if (!(obj instanceof FigComponentInstance))
    4
    if (!(obj instanceof FigObject))
    Differences
    Expression1Expression2Difference
    org.argouml.uml.diagram.deployment.ui.FigComponentInstanceorg.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
    FigComponentInstance figComponentInstance = (FigComponentInstance)obj;
    8
    FigComponentInstance figComponentInstance = (FigComponentInstance)obj;
    6
    FigObject fo = (FigObject)obj;
    Differences
    Expression1Expression2Difference
    org.argouml.uml.diagram.deployment.ui.FigComponentInstanceorg.argouml.uml.diagram.deployment.ui.FigObjectSUBCLASS_TYPE_MISMATCH
    figComponentInstancefoVARIABLE_NAME_MISMATCH
    org.argouml.uml.diagram.deployment.ui.FigComponentInstanceorg.argouml.uml.diagram.deployment.ui.FigObjectSUBCLASS_TYPE_MISMATCH
    org.argouml.uml.diagram.deployment.ui.FigComponentInstanceorg.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;
    9
    if (figComponentInstance != null)
    9
    if (figComponentInstance != null)
    7
    if (fo != null)
    Differences
    Expression1Expression2Difference
    figComponentInstancefoVARIABLE_NAME_MISMATCH
    org.argouml.uml.diagram.deployment.ui.FigComponentInstanceorg.argouml.uml.diagram.deployment.ui.FigObjectSUBCLASS_TYPE_MISMATCH
    7
    if (fo != null)
    10
    Object coi = figComponentInstance.getOwner();
    10
    Object coi = figComponentInstance.getOwner();
    8
    Object mobj = fo.getOwner();
    Differences
    Expression1Expression2Difference
    coimobjVARIABLE_NAME_MISMATCH
    figComponentInstancefoVARIABLE_NAME_MISMATCH
    org.argouml.uml.diagram.deployment.ui.FigComponentInstanceorg.argouml.uml.diagram.deployment.ui.FigObjectSUBCLASS_TYPE_MISMATCH
    8
    Object mobj = fo.getOwner();
    11
    if (coi != null)
    11
    if (coi != null)
    9
    if (mobj != null)
    Differences
    Expression1Expression2Difference
    coimobjVARIABLE_NAME_MISMATCH
    9
    if (mobj != null)
    12
    Collection col = Model.getFacade().getClassifiers(coi);
    12
    Collection col = Model.getFacade().getClassifiers(coi);
    10
    Collection col = Model.getFacade().getClassifiers(mobj);
    Differences
    Expression1Expression2Difference
    coimobjVARIABLE_NAME_MISMATCH
    10
    Collection col = Model.getFacade().getClassifiers(mobj);
    13
    if (col.size() > 0)
    11
    if (col.size() > 0)
    14
    continue;
    12
    continue;
    15
    if (offs == null)
    13
    if (offs == null)
    16
    offs = new ListSet();
    14
    offs = new ListSet();
    17
    offs.add(deploymentDiagram);
    17
    offs.add(deploymentDiagram);
    15
    offs.add(dd);
    Differences
    Expression1Expression2Difference
    deploymentDiagramddVARIABLE_NAME_MISMATCH
    15
    offs.add(dd);
    18
    offs.add(figComponentInstance);
    18
    offs.add(figComponentInstance);
    16
    offs.add(fo);
    Differences
    Expression1Expression2Difference
    figComponentInstancefoVARIABLE_NAME_MISMATCH
    org.argouml.uml.diagram.deployment.ui.FigComponentInstanceorg.argouml.uml.diagram.deployment.ui.FigObjectSUBCLASS_TYPE_MISMATCH
    16
    offs.add(fo);
    Precondition Violations (2)
    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