for (int i = 0; i < profiles.count(); i++) { XmlElement profile = profiles.getElement(i); String n = profile.getAttribute("name"); if (name.equalsIgnoreCase(n)) { return profile; } } return null;
for (int i = 0; i < parent.count(); i++) { XmlElement child = parent.getElement(i); if (child.getAttribute("name").equals(name)) { return child; } } return null;
Clone fragments detected by clone detection tool
File path: /columba-1.4-src/core/src/main/java/org/columba/core/gui/profiles/ProfileManager.java File path: /columba-1.4-src/mail/src/main/java/org/columba/mail/gui/config/columns/ColumnConfigDialog.java
Method name: XmlElement getXmlElementForName(String) Method name: XmlElement findColumn(XmlElement, String)
Number of AST nodes: 6 Number of AST nodes: 5
1
for (int i = 0; i < profiles.count(); i++) {
1
for (int i = 0; i < parent.count(); i++) {
2
			XmlElement profile = profiles.getElement(i);
2
			XmlElement child = parent.getElement(i);
3
			String n = profile.getAttribute("name");
3
			if (child.getAttribute("name")
4
			if (name.equalsIgnoreCase(n)) {
4
.equals(name)) {
5
				return profile;
5
				return child;
6
			}
6
			}
7
		}
7
		}
8
		return null;
8
		return null;
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.3
Clones locationClones are in different classes
Number of node comparisons11
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)8.5
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    for (int i = 0; i < profiles.count(); i++)
    1
    for (int i = 0; i < profiles.count(); i++)
    1
    for (int i = 0; i < parent.count(); i++)
    Differences
    Expression1Expression2Difference
    profilesparentVARIABLE_NAME_MISMATCH
    1
    for (int i = 0; i < parent.count(); i++)
    2
    XmlElement profile = profiles.getElement(i);
    2
    XmlElement profile = profiles.getElement(i);
    2
    XmlElement child = parent.getElement(i);
    Differences
    Expression1Expression2Difference
    profilechildVARIABLE_NAME_MISMATCH
    profilesparentVARIABLE_NAME_MISMATCH
    2
    XmlElement child = parent.getElement(i);
    3
    String n = profile.getAttribute("name");
    3
    String n = profile.getAttribute("name");
    Preondition Violations
    Unmatched statement String n=profile.getAttribute("name"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                      
    4
    if (name.equalsIgnoreCase(n))
    4
    if (name.equalsIgnoreCase(n))
    3
    if (child.getAttribute("name").equals(name))
    Differences
    Expression1Expression2Difference
    nnameVARIABLE_NAME_MISMATCH
    equalsIgnoreCaseequalsMETHOD_INVOCATION_NAME_MISMATCH
    namechild.getAttribute("name")TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression name.equalsIgnoreCase(n) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression child.getAttribute("name").equals(name) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression child.getAttribute("name") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    if (child.getAttribute("name").equals(name))
    5
    return profile;
    5
    return profile;
    4
    return child;
    Differences
    Expression1Expression2Difference
    profilechildVARIABLE_NAME_MISMATCH
    4
    return child;
    6
    return null;
    5
    return null;
    Precondition Violations (6)
    Row Violation
    1Unmatched statement String n=profile.getAttribute("name"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Expression name.equalsIgnoreCase(n) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression child.getAttribute("name").equals(name) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression child.getAttribute("name") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Clone fragment #1 returns variables profile , while Clone fragment #2 returns variables
    6The refactoring of the clones is infeasible, because classes org.columba.core.gui.profiles.ProfileManager and org.columba.mail.gui.config.columns.ColumnConfigDialog do not have a common superclass