/** * If there are instances that have no classifiers they belong to * the returned ListSet is not null. Then in the ListSet * are the UMLDeploymentDiagram and all FigObjects, FigComponentInstances * and FigMNodeInstances with no classifier. * * @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 FigNodeModelElement)) { continue; } FigNodeModelElement figNodeModelElement = (FigNodeModelElement) obj; if (figNodeModelElement != null && (Model.getFacade().isAInstance( figNodeModelElement.getOwner()))) { Object instance = figNodeModelElement.getOwner(); if (instance != null) { Collection col = Model.getFacade().getClassifiers(instance); if (col.size() > 0) { continue; } } if (offs == null) { offs = new ListSet(); offs.add(dd); } offs.add(figNodeModelElement); } } return offs; }
/** * If there are instances that have no classifiers they belong to * the returned vector-set is not null. Then in the vector-set * are the UMLSequenceDiagram and all FigObjects, FigComponentInstances * and FigMNodeInstances with no classifier. * * @param sd the diagram to check * @return the set of offenders */ public ListSet computeOffenders(ArgoDiagram sd) { Collection figs = sd.getLayer().getContents(); ListSet offs = null; for (Object obj : figs) { if (!(obj instanceof FigNodeModelElement)) { continue; } FigNodeModelElement fn = (FigNodeModelElement) obj; if (fn != null && (Model.getFacade().isAInstance(fn.getOwner()))) { Object minst = fn.getOwner(); if (minst != null) { Collection col = Model.getFacade().getClassifiers(minst); if (col.size() > 0) { continue; } } if (offs == null) { offs = new ListSet(); offs.add(sd); } offs.add(fn); } } retur
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/cognitive/critics/CrInstanceWithoutClassifier.java File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/cognitive/critics/CrSeqInstanceWithoutClassifier.java
Method name: ListSet computeOffenders(UMLDeploymentDiagram) Method name: ListSet computeOffenders(ArgoDiagram)
Number of AST nodes: 15 Number of AST nodes: 14
1
/**
1
/**
2
     * If there are instances that have no classifiers they belong to
2
     * If there are instances that have no classifiers they belong to
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 FigObjects, FigComponentInstances
4
     * are the UMLSequenceDiagram and all FigObjects, FigComponentInstances
5
     * and FigMNodeInstances with no classifier.
5
     * and FigMNodeInstances with no classifier.
6
     *
6
     *
7
     * @param dd the diagram to check
7
     * @param sd 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(ArgoDiagram sd) {
11
	Collection figs = dd.getLayer().getContents();
11
    	Collection figs = sd.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 FigNodeModelElement)) {
15
	    Object obj = figIter.next();
15
    			continue;
16
	    if (!(obj instanceof FigNodeModelElement)) {
16
    		}
17
	        continue;
17
    		FigNodeModelElement fn = (FigNodeModelElement) obj;
18
	    }
18
    		if (fn != null && (Model.getFacade().isAInstance(fn.getOwner()))) {
19
	    FigNodeModelElement figNodeModelElement = (FigNodeModelElement) obj;
19
    			Object minst = fn.getOwner();
20
	    if (figNodeModelElement != null
20
    			if (minst != null) {
21
                && (Model.getFacade().isAInstance(
21
    				Collection col = Model.getFacade().getClassifiers(minst);
22
                        figNodeModelElement.getOwner()))) {
22
    				if (col.size() > 0) {
23
		Object instance = figNodeModelElement.getOwner();
23
    					continue;
24
		if (instance != null) {
24
    				}
25
		    Collection col = Model.getFacade().getClassifiers(instance);
25
    			}
26
		    if (col.size() > 0) {
26
    			if (offs == null) {
27
		        continue;
27
    				offs = new ListSet();
28
		    }
28
    				offs.add(sd);
29
		}
29
    			}
30
		if (offs == null) {
30
    			offs.add(fn);
31
		    offs = new ListSet();
31
    		}
32
		    offs.add(dd);
32
    	}
33
		}
33
    	retur
34
		offs.add(figNodeModelElement);
35
	    }
36
	}
37
	return offs;
38
    }
  1. {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.857
    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 FigNodeModelElement))
    4
    if (!(obj instanceof FigNodeModelElement))
    7
    continue;
    5
    continue;
    8
    FigNodeModelElement figNodeModelElement = (FigNodeModelElement)obj;
    8
    FigNodeModelElement figNodeModelElement = (FigNodeModelElement)obj;
    6
    FigNodeModelElement fn = (FigNodeModelElement)obj;
    Differences
    Expression1Expression2Difference
    figNodeModelElementfnVARIABLE_NAME_MISMATCH
    6
    FigNodeModelElement fn = (FigNodeModelElement)obj;
    9
    if (figNodeModelElement != null && (Model.getFacade().isAInstance(figNodeModelElement.getOwner())))
    9
    if (figNodeModelElement != null && (Model.getFacade().isAInstance(figNodeModelElement.getOwner())))
    7
    if (fn != null && (Model.getFacade().isAInstance(fn.getOwner())))
    Differences
    Expression1Expression2Difference
    figNodeModelElementfnVARIABLE_NAME_MISMATCH
    figNodeModelElementfnVARIABLE_NAME_MISMATCH
    7
    if (fn != null && (Model.getFacade().isAInstance(fn.getOwner())))
    10
    Object instance = figNodeModelElement.getOwner();
    10
    Object instance = figNodeModelElement.getOwner();
    8
    Object minst = fn.getOwner();
    Differences
    Expression1Expression2Difference
    instanceminstVARIABLE_NAME_MISMATCH
    figNodeModelElementfnVARIABLE_NAME_MISMATCH
    8
    Object minst = fn.getOwner();
    11
    if (instance != null)
    11
    if (instance != null)
    9
    if (minst != null)
    Differences
    Expression1Expression2Difference
    instanceminstVARIABLE_NAME_MISMATCH
    9
    if (minst != null)
    12
    Collection col = Model.getFacade().getClassifiers(instance);
    12
    Collection col = Model.getFacade().getClassifiers(instance);
    10
    Collection col = Model.getFacade().getClassifiers(minst);
    Differences
    Expression1Expression2Difference
    instanceminstVARIABLE_NAME_MISMATCH
    10
    Collection col = Model.getFacade().getClassifiers(minst);
    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(dd);
    17
    offs.add(dd);
    15
    offs.add(sd);
    Differences
    Expression1Expression2Difference
    ddsdVARIABLE_NAME_MISMATCH
    org.argouml.uml.diagram.deployment.ui.UMLDeploymentDiagramorg.argouml.uml.diagram.ArgoDiagramSUBCLASS_TYPE_MISMATCH
    15
    offs.add(sd);
    18
    offs.add(figNodeModelElement);
    18
    offs.add(figNodeModelElement);
    16
    offs.add(fn);
    Differences
    Expression1Expression2Difference
    figNodeModelElementfnVARIABLE_NAME_MISMATCH
    16
    offs.add(fn);
    Precondition Violations (0)
    Row Violation