From 87566acc03ead5c69f6e421fd852f343b705e0d7 Mon Sep 17 00:00:00 2001 From: Faisal Hameed Date: Wed, 18 May 2016 19:57:49 +0500 Subject: [PATCH] Fixing squid:S1066 - Collapsible "if" statements should be merged. --- .../main/java/de/sopa/helper/LevelSolver.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/de/sopa/helper/LevelSolver.java b/app/src/main/java/de/sopa/helper/LevelSolver.java index bfee66b5..11d0389b 100644 --- a/app/src/main/java/de/sopa/helper/LevelSolver.java +++ b/app/src/main/java/de/sopa/helper/LevelSolver.java @@ -70,16 +70,16 @@ private boolean solve(Level level, int maxDepth, int currentDepth, List p for (int column = 0; column < columns - 2; column++) { gameFieldService.shiftLine(level, false, column, 1); - if (currentDepth + 1 < highestHit && solve(level, maxDepth, currentDepth + 1, possibleSolutions)) { - if (currentDepth + 1 < highestHit) - return true; + if (currentDepth + 1 < highestHit && solve(level, maxDepth, currentDepth + 1, possibleSolutions) + && currentDepth + 1 < highestHit) { + return true; } gameFieldService.shiftLine(level, false, column, -2); - if (currentDepth + 1 < highestHit && solve(level, maxDepth, currentDepth + 1, possibleSolutions)) { - if (currentDepth + 1 < highestHit) - return true; + if (currentDepth + 1 < highestHit && solve(level, maxDepth, currentDepth + 1, possibleSolutions) + && currentDepth + 1 < highestHit) { + return true; } // restore state @@ -89,16 +89,16 @@ private boolean solve(Level level, int maxDepth, int currentDepth, List p for (int row = 0; row < rows - 2; row++) { gameFieldService.shiftLine(level, true, row, 1); - if (currentDepth + 1 < highestHit && solve(level, maxDepth, currentDepth + 1, possibleSolutions)) { - if (currentDepth + 1 < highestHit) - return true; + if (currentDepth + 1 < highestHit && solve(level, maxDepth, currentDepth + 1, possibleSolutions) + && currentDepth + 1 < highestHit) { + return true; } gameFieldService.shiftLine(level, true, row, -2); - if (currentDepth + 1 < highestHit && solve(level, maxDepth, currentDepth + 1, possibleSolutions)) { - if (currentDepth + 1 < highestHit) - return true; + if (currentDepth + 1 < highestHit && solve(level, maxDepth, currentDepth + 1, possibleSolutions) + && currentDepth + 1 < highestHit) { + return true; } // restore state