'if' statement with identical branches or common parts
Reports if statements in which common parts can be extracted from the branches.
These common parts are independent from the condition and make if statements harder to understand.
Example:
if (x > 12) {
doSomethingBefore();
doSomethingDifferent1();
doSomethingAfter();
} else {
doSomethingBefore();
doSomethingDifferent2();
doSomethingAfter();
}After the quick-fix is applied:
doSomethingBefore();
if (x > 12) {
doSomethingDifferent1();
} else {
doSomethingDifferent2();
}
doSomethingAfter();- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
IfStatementWithIdenticalBranches
Updated in 2018.1
Here you can find the description of settings available for the 'if' statement with identical branches or common parts inspection, and the reference of their default values.
You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:
//noinspection IfStatementWithIdenticalBranchesnote
Actual comment syntax will depend on the code language you are working with
More detailed instructions as well as other ways and options that you have can be found in the product documentation:
Inspection Details | |
|---|---|
By default bundled with: |