/** * 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 node-instances that have an enclosing Fig * the returned vector-set is not null. Then in the vector-set * are the UMLDeploymentDiagram and all FigMNodeInstances with an * enclosing Fig * * @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 FigNodeInstance)) { continue; } FigNodeInstance fn = (FigNodeInstance) obj; if (fn != null) { Object noi = fn.getOwner(); if (noi != null) { Collection col = Model.getFacade().getClassifiers(noi); if (col.size() > 0) { continue; } } if (offs == null) { offs = new ListSet(); offs.add(dd); } offs.add(fn); } } 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/CrNodeInstanceWithoutClassifier.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 node-instances that have an enclosing Fig
3
     * the returned ListSet is not null. Then in the ListSet
3
     * the returned vector-set is not null. Then in the vector-set
4
     * are the UMLDeploymentDiagram and all FigComponentInstances with no
4
     * are the UMLDeploymentDiagram and all FigMNodeInstances with an
5
     * enclosing FigMNodeInstance
5
     * enclosing Fig
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 FigNodeInstance)) {
15
	while (figIter.hasNext()) {
15
	        continue;
16
	    Object obj = figIter.next();
16
	    }
17
	    if (!(obj instanceof FigComponentInstance)) {
17
	    FigNodeInstance fn = (FigNodeInstance) obj;
18
	        continue;
18
	    if (fn != null) {
19
	    }
19
		Object noi = fn.getOwner();
20
	    FigComponentInstance figComponentInstance =
20
		if (noi != null) {
21
	        (FigComponentInstance) obj;
21
		    Collection col = Model.getFacade().getClassifiers(noi);
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(fn);
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 FigNodeInstance))
    Differences
    Expression1Expression2Difference
    org.argouml.uml.diagram.deployment.ui.FigComponentInstanceorg.argouml.uml.diagram.deployment.ui.FigNodeInstanceSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression obj instanceof FigNodeInstance cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4
    if (!(obj instanceof FigNodeInstance))
    7
    continue;
    5
    continue;
    8
    FigComponentInstance figComponentInstance = (FigComponentInstance)obj;
    8
    FigComponentInstance figComponentInstance = (FigComponentInstance)obj;
    6
    FigNodeInstance fn = (FigNodeInstance)obj;
    Differences
    Expression1Expression2Difference
    org.argouml.uml.diagram.deployment.ui.FigComponentInstanceorg.argouml.uml.diagram.deployment.ui.FigNodeInstanceSUBCLASS_TYPE_MISMATCH
    figComponentInstancefnVARIABLE_NAME_MISMATCH
    org.argouml.uml.diagram.deployment.ui.FigComponentInstanceorg.argouml.uml.diagram.deployment.ui.FigNodeInstanceSUBCLASS_TYPE_MISMATCH
    org.argouml.uml.diagram.deployment.ui.FigComponentInstanceorg.argouml.uml.diagram.deployment.ui.FigNodeInstanceSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (FigNodeInstance)obj cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    FigNodeInstance fn = (FigNodeInstance)obj;
    9
    if (figComponentInstance != null)
    9
    if (figComponentInstance != null)
    7
    if (fn != null)
    Differences
    Expression1Expression2Difference
    figComponentInstancefnVARIABLE_NAME_MISMATCH
    org.argouml.uml.diagram.deployment.ui.FigComponentInstanceorg.argouml.uml.diagram.deployment.ui.FigNodeInstanceSUBCLASS_TYPE_MISMATCH
    7
    if (fn != null)
    10
    Object coi = figComponentInstance.getOwner();
    10
    Object coi = figComponentInstance.getOwner();
    8
    Object noi = fn.getOwner();
    Differences
    Expression1Expression2Difference
    coinoiVARIABLE_NAME_MISMATCH
    figComponentInstancefnVARIABLE_NAME_MISMATCH
    org.argouml.uml.diagram.deployment.ui.FigComponentInstanceorg.argouml.uml.diagram.deployment.ui.FigNodeInstanceSUBCLASS_TYPE_MISMATCH
    8
    Object noi = fn.getOwner();
    11
    if (coi != null)
    11
    if (coi != null)
    9
    if (noi != null)
    Differences
    Expression1Expression2Difference
    coinoiVARIABLE_NAME_MISMATCH
    9
    if (noi != null)
    12
    Collection col = Model.getFacade().getClassifiers(coi);
    12
    Collection col = Model.getFacade().getClassifiers(coi);
    10
    Collection col = Model.getFacade().getClassifiers(noi);
    Differences
    Expression1Expression2Difference
    coinoiVARIABLE_NAME_MISMATCH
    10
    Collection col = Model.getFacade().getClassifiers(noi);
    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(fn);
    Differences
    Expression1Expression2Difference
    figComponentInstancefnVARIABLE_NAME_MISMATCH
    org.argouml.uml.diagram.deployment.ui.FigComponentInstanceorg.argouml.uml.diagram.deployment.ui.FigNodeInstanceSUBCLASS_TYPE_MISMATCH
    16
    offs.add(fn);
    Precondition Violations (2)
    Row Violation
    1Expression obj instanceof FigNodeInstance cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression (FigNodeInstance)obj cannot be parameterized, because it has dependencies to/from statements that will be extracted