@Override public boolean predicate2(Object dm, Designer dsgr) { if (!(Model.getFacade().isACompositeState(dm))) { return NO_PROBLEM; } Object cs = /*(MCompositeState)*/ dm; // if this composite state is not attached to a statemachine // it is not the toplevel composite state. if (Model.getFacade().getStateMachine(cs) == null) { return NO_PROBLEM; } Collection peers = Model.getFacade().getSubvertices(cs); int initialStateCount = 0; if (peers == null) { return PROBLEM_FOUND; } for (Iterator iter = peers.iterator(); iter.hasNext();) { Object sv = iter.next(); if (Model.getFacade().isAPseudostate(sv) && (Model.getFacade().getKind(sv).equals( Model.getPseudostateKind().getInitial()))) { initialStateCount++; } } if (initialStateCount == 0) { return PROBLEM_FOUND; } return NO_PROBLEM; }
@Override public boolean predicate2(Object dm, Designer dsgr) { if (!(Model.getFacade().isAPseudostate(dm))) { return NO_PROBLEM; } Object k = Model.getFacade().getKind(dm); if (!Model.getFacade().equalsPseudostateKind( k, Model.getPseudostateKind().getInitial())) { return NO_PROBLEM; } // container state / composite state Object cs = Model.getFacade().getContainer(dm); if (cs == null) { LOG.debug("null parent state"); return NO_PROBLEM; } int initialStateCount = 0; Collection peers = Model.getFacade().getSubvertices(cs); for (Object sv : peers) { if (Model.getFacade().isAPseudostate(sv) && Model.getFacade(). equalsPseudostateKind( Model.getFacade().getKind(sv), Model.getPseudostateKind().getInitial())) { initialStateCount++; } } if (initialStateCount > 1) { return PROBLEM_FOUND; } return NO_PROBLEM; }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/cognitive/critics/CrNoInitialState.java File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/cognitive/critics/CrMultipleInitialStates.java
Method name: boolean predicate2(Object, Designer) Method name: boolean predicate2(Object, Designer)
Number of AST nodes: 4 Number of AST nodes: 3
1
@Override
1
@Override
2
    public boolean predicate2(Object dm, Designer dsgr) {
2
    public boolean predicate2(Object dm, Designer dsgr) {
3
	if (!(Model.getFacade().isACompositeState(dm))) {
3
        if (!(Model.getFacade().isAPseudostate(dm))) {
4
	    return NO_PROBLEM;
4
            return NO_PROBLEM;
5
	}
5
        }
6
	Object cs = /*(MCompositeState)*/ dm;
6
        Object k = Model.getFacade().getKind(dm);
7
7
        if (!Model.getFacade().equalsPseudostateKind(
8
	// if this composite state is not attached to a statemachine
8
                k,
9
	// it is not the toplevel composite state.
9
                Model.getPseudostateKind().getInitial())) {
10
	if (Model.getFacade().getStateMachine(cs) == null) {
10
	    return NO_PROBLEM;
11
	    return NO_PROBLEM;
11
        }
12
	}
12
13
	Collection peers = Model.getFacade().getSubvertices(cs);
13
        // container state / composite state
14
	int initialStateCount = 0;
14
        Object cs = Model.getFacade().getContainer(dm);
15
	if (peers == null) {
15
        if (cs == null) {
16
	    return PROBLEM_FOUND;
16
            LOG.debug("null parent state");
17
	}
17
            return NO_PROBLEM;
18
	for (Iterator iter = peers.iterator(); iter.hasNext();) {
18
        }
19
	    Object sv = iter.next();
19
        
20
	    if (Model.getFacade().isAPseudostate(sv)
20
        int initialStateCount = 0;
21
		&& (Model.getFacade().getKind(sv).equals(
21
        Collection peers = Model.getFacade().getSubvertices(cs);
22
                        Model.getPseudostateKind().getInitial()))) {
22
        for (Object sv : peers) {
23
	        initialStateCount++;
23
            if (Model.getFacade().isAPseudostate(sv)
24
	    }
24
                && Model.getFacade().
25
	}
25
                	equalsPseudostateKind(
26
	if (initialStateCount == 0) {
26
                	        Model.getFacade().getKind(sv),
27
	    return PROBLEM_FOUND;
27
                	        Model.getPseudostateKind().getInitial())) {
28
	}
28
                initialStateCount++;
29
	return NO_PROBLEM;
29
            }
30
    }
30
        }
31
        if (initialStateCount > 1) {
32
            return PROBLEM_FOUND;
33
        }
34
        return NO_PROBLEM;
35
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    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.800
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    10
    for (Iterator iter = peers.iterator(); iter.hasNext(); )
    12
    for (Object sv : peers)
    11
    Object sv = iter.next();
                                                        
    12
    if (Model.getFacade().isAPseudostate(sv) && (Model.getFacade().getKind(sv).equals(Model.getPseudostateKind().getInitial())))
    12
    if (Model.getFacade().isAPseudostate(sv) && (Model.getFacade().getKind(sv).equals(Model.getPseudostateKind().getInitial())))
    13
    if (Model.getFacade().isAPseudostate(sv) && Model.getFacade().equalsPseudostateKind(Model.getFacade().getKind(sv), Model.getPseudostateKind().getInitial()))
    Differences
    Expression1Expression2Difference
    (Model.getFacade().getKind(sv).equals(Model.getPseudostateKind().getInitial()))Model.getFacade().equalsPseudostateKind(Model.getFacade().getKind(sv),Model.getPseudostateKind().getInitial())TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression Model.getFacade().equalsPseudostateKind(Model.getFacade().getKind(sv),Model.getPseudostateKind().getInitial()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13
    if (Model.getFacade().isAPseudostate(sv) && Model.getFacade().equalsPseudostateKind(Model.getFacade().getKind(sv), Model.getPseudostateKind().getInitial()))
    13
    initialStateCount++;
    14
    initialStateCount++;
    Precondition Violations (1)
    Row Violation
    1Expression Model.getFacade().equalsPseudostateKind(Model.getFacade().getKind(sv),Model.getPseudostateKind().getInitial()) cannot be parameterized, because it has dependencies to/from statements that will be extracted