Distinguish variables | If this option is checked, the similar contents with different variable names will be recognized as different. If this option is not checked, such contents will be recognized as duplicated: public static void main(String[] args) {
int i = 0;
int j = 0;
if (i == j) {
System.out.println("sum of " + i + " and " + j + " = " + i + j);
}
long k = 0;
long n = 0;
if (k == n) {
System.out.println("sum of " + k + " and " + n + " = " + k + n);
}
}
|
Distinguish fields | If this option is checked, the similar contents with different field names will be recognized as different. If this option is not checked, such contents will be recognized as duplicated: myTable.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
/*.....**/
});
myTree.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
/*.....**/
});
|
Distinguish methods | If this option is checked, the methods of similar structure will be recognized as different. If this option is not checked, such methods will be recognized as duplicated. In this case, they can be extracted and reused. Initial version: public void buildCanceled(Build build, SessionData data) {
/* ... **/
for (IListener listener : getListeners()) {
listener.buildCanceled(build, data);
}
}
public void buildFinished(Build build, SessionData data) {
/* ... **/
for (IListener listener : getListeners()) {
listener.buildFinished(build, data);
}
}
After analysiing code for duplicates without distinguishing methods, the duplicated fragments can be extracted: public void buildCanceled(final Build build, final SessionData data) {
enumerateListeners(new Processor() {
public void process(final IListener listener) {
listener.buildCanceled(build, data);
}
});
}
public void buildFinished(final Build build, final SessionData data) {
enumerateListeners(new Processor() {
public void process(final IListener listener) {
listener.buildFinished(build, data);
}
});
}
private void enumerateListeners(Processor processor) {/* ... **/
for (IListener listener : getListeners()) {
processor.process(listener);
}
}
private interface Processor {
void process(IListener listener);
}
|
Distinguish types | If this option is checked, the similar code fragments with different type names will be recognized as different. If this option is not checked, such code fragments will be recognized as duplicates. new MyIDE().updateStatus()
new TheirIDE().updateStatus()
|
Distinguish literals | If this option is checked, similar line of code with different litarels will be considered different If this option is not checked, such lines will be recognized as duplicates. myWatchedLabel.setToolTipText("Not Logged In");
myWatchedLabel.setToolTipText("Logging In...");
|
Ignore duplicates with complexity lower than | Complexity of the source code is defined by the amount of statements, expressions, declarations and method calls. Complexity of each of them is defined by its cost. Summarized costs of all these elements of the source code fragment yields the total complexity. Use this field to specify the lowest level of complexity of the source code to be taken into consideration when detecting duplicates. For meaningful results start with value 10. |
Ignore duplicate subexpressions with complexity lower than | Use this field to specify the lowest level of complexity of subexpressions to be taken into consideration when detecting duplicates. |
Check if Subexpression Can be Extracted | If this option is checked, the duplicated subexpressions can be extracted. |