Java
'if' statement with identical branches or common parts
Info
New
Last modified: 03 December 2024 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.
Inspection Details | |
---|---|
By default bundled with: | |
Can be installed with plugin: | Java, 243.23126 |
Thanks for your feedback!
Was this page helpful?