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 | } | |
See real code fragment | See real code fragment |
Number of mapped statements | 11 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 0.0 |
Similarity Score | 0.714 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4 | while (figIter.hasNext()) | 3 | for (Object obj : figs) | |||||||||||||||||||||
5 | Object obj = figIter.next(); | | ||||||||||||||||||||||
6 | if (!(obj instanceof FigClass)) |
| 4 | if (!(obj instanceof FigObject)) | ||||||||||||||||||||
7 | continue; | 5 | continue; | |||||||||||||||||||||
8 | FigClass fc = (FigClass)obj; |
| 6 | FigObject fo = (FigObject)obj; | ||||||||||||||||||||
|
| 7 | Fig enclosing = fo.getEnclosingFig(); | |||||||||||||||||||||
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())))) | ||||||||||||||||||||
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); |
| 12 | offs.add(fo); |
Row | Violation |
---|---|
1 | Expression obj instanceof FigObject cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression (FigObject)obj cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | 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 |
4 | Expression fc.getEnclosingFig() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | Expression Model.getFacade().isAComponent(fc.getEnclosingFig().getOwner()) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Clone fragment #1 returns variables offs , while Clone fragment #2 returns variables fo, offs |