String result = toFormat;
try {
result = formatter.reformat(toFormat);
} catch (IllegalStateException e) {
s_log.error("format: Formatting SQL failed: "+e.getMessage(), e);
}
return result;
int result = defaultNum;
try {
result = Integer.parseInt(numberStr);
} catch (NumberFormatException e) {
s_log.error("getNumber: Unexpected exception - "
+ e.getMessage(), e);
}
return result;
Clone fragments detected by clone detection tool
File path: /sql12/app/src/net/sourceforge/squirrel_sql/client/session/mainpanel/objecttree/tabs/FormattedSourceTab.java
|
|
File path: /sql12/plugins/informix/src/net/sourceforge/squirrel_sql/plugins/informix/exception/InformixExceptionFormatter.java
|
Method name: String format(String)
|
|
Method name: int getNumber(String, int)
|
Number of AST nodes: 4
|
|
Number of AST nodes: 4
|
|
1 | String result = toFormat;↵ | | 1 | int result = defaultNum;↵
|
2 | try {↵ | | 2 | try {↵
|
3 | result = formatter.reformat(toFormat);↵ | | 3 | result = Integer.parseInt(numberStr);↵
|
4 | } catch (IllegalStateException e) {↵ | | 4 | } catch (NumberFormatException e) {↵
|
5 | s_log.error("format: Formatting SQL failed: "+↵ | | 5 | s_log.error("getNumber: Unexpected exception - "↵
|
6 | e.getMessage(), e);↵ | | 6 | + e.getMessage(), e);↵
|
7 | }↵ | | 7 | }↵
|
8 | return result; | | 8 | return result;
|
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.5 |
Clones location | Clones are in different classes |
Number of node comparisons | 8 |
-
{Non-refactorable}
Mapping Summary
Number of mapped statements | 1 |
Number of unmapped statements in the first code fragment | 3 |
Number of unmapped statements in the second code fragment | 3 |
Time elapsed for statement mapping (ms) | 1.4 |
Clone type | Type 2 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
| | | 1 | int result = defaultNum; |
1 | String result = toFormat; | | | |
2 | try | | 2 | try |
| | | 3 | result = Integer.parseInt(numberStr); |
3 | result = formatter.reformat(toFormat); | | | |
| | | 4 | return result; |
4 | return result; | | | |
Precondition Violations (5)
Row |
Violation |
1 | Unmatched statement result=Integer.parseInt(numberStr); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
2 | Unmatched statement result=formatter.reformat(toFormat); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
3 | Unmatched return result; |
4 | Unmatched return result; |
5 | The refactoring of the clones is infeasible, because classes net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.FormattedSourceTab and net.sourceforge.squirrel_sql.plugins.informix.exception.InformixExceptionFormatter do not have a common superclass |