Issue #1555: Collapse if statement

Fixes `IfStatementWithIdenticalBranches` inspection violation.

Description:
>Reports if statements with identical "then" and else branches. Such statements are almost certainly programmer error.
This commit is contained in:
Michal Kordas 2015-08-30 21:58:31 +02:00 committed by Roman Ivanov
parent 74566f21a2
commit 4b95f33697
1 changed files with 2 additions and 4 deletions

View File

@ -49,14 +49,12 @@ public class MethodCallHandler extends AbstractExpressionHandler {
if (getParent() instanceof MethodCallHandler) {
final MethodCallHandler container =
(MethodCallHandler) getParent();
if (areOnSameLine(container.getMainAst(), getMainAst())) {
if (areOnSameLine(container.getMainAst(), getMainAst())
|| isChainedMethodCallWrapped()) {
indentLevel = container.getLevel();
}
// we should increase indentation only if this is the first
// chained method call which was moved to the next line
else if (isChainedMethodCallWrapped()) {
indentLevel = container.getLevel();
}
else {
indentLevel = new IndentLevel(container.getLevel(), getBasicOffset());
}