String title = null; for (String s : TITLES) { if (nameInputStr.endsWith(s)) { title = s; break; } } return title;
String salutation = null; for (String s : SALUTATIONS) { if (nameInputStr.startsWith(s)) { salutation = s; break; } } return salutation;
Clone fragments detected by clone detection tool
File path: /columba-1.4-src/core/src/main/java/org/columba/core/util/NameParser.java File path: /columba-1.4-src/core/src/main/java/org/columba/core/util/NameParser.java
Method name: String findTitle(String) Method name: String findSalutation(String)
Number of AST nodes: 6 Number of AST nodes: 6
1
String title = null;
1
String salutation = null;
2
		for (String s : TITLES) {
2
		for (String s : SALUTATIONS) {
3
			if (nameInputStr.endsWith(s)) {
3
			if (nameInputStr.startsWith(s)) {
4
				title = s;
4
				salutation = s;
5
				break;
5
				break;
6
			}
6
			}
7
		}
7
		}
8
		return title;
8
		return salutation;
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.2
Clones locationClones are declared in the same class
Number of node comparisons14
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    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.8
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    String title = null;
    1
    String title = null;
    1
    String salutation = null;
    Differences
    Expression1Expression2Difference
    titlesalutationVARIABLE_NAME_MISMATCH
    1
    String salutation = null;
    2
    for (String s : TITLES)
    2
    for (String s : TITLES)
    2
    for (String s : SALUTATIONS)
    Differences
    Expression1Expression2Difference
    TITLESSALUTATIONSVARIABLE_NAME_MISMATCH
    2
    for (String s : SALUTATIONS)
    3
    if (nameInputStr.endsWith(s))
    3
    if (nameInputStr.endsWith(s))
    3
    if (nameInputStr.startsWith(s))
    Differences
    Expression1Expression2Difference
    endsWithstartsWithMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression nameInputStr.endsWith(s) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression nameInputStr.startsWith(s) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    if (nameInputStr.startsWith(s))
    4
    title = s;
    4
    title = s;
    4
    salutation = s;
    Differences
    Expression1Expression2Difference
    titlesalutationVARIABLE_NAME_MISMATCH
    4
    salutation = s;
    5
    break;
    5
    break;
    6
    return title;
    6
    return title;
    6
    return salutation;
    Differences
    Expression1Expression2Difference
    titlesalutationVARIABLE_NAME_MISMATCH
    6
    return salutation;
    Precondition Violations (2)
    Row Violation
    1Expression nameInputStr.endsWith(s) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression nameInputStr.startsWith(s) cannot be parameterized, because it has dependencies to/from statements that will be extracted