diff --git a/src/main/java/org/codetracker/BlockTrackerChangeHistory.java b/src/main/java/org/codetracker/BlockTrackerChangeHistory.java index 25a67334b22..7a911f1d3e1 100644 --- a/src/main/java/org/codetracker/BlockTrackerChangeHistory.java +++ b/src/main/java/org/codetracker/BlockTrackerChangeHistory.java @@ -22,8 +22,11 @@ import org.codetracker.change.Change; import org.codetracker.change.ChangeFactory; import org.codetracker.change.Introduced; +import org.codetracker.change.block.BlockBodyAdded; +import org.codetracker.change.block.BlockBodyRemoved; import org.codetracker.change.block.BlockSignatureFormatChange; import org.codetracker.change.block.ElseBlockAdded; +import org.codetracker.change.block.ElseBodyBlockAdded; import org.codetracker.change.block.ExpressionChange; import org.codetracker.change.block.MergeBlock; import org.codetracker.change.block.ReplaceConditionalWithTernary; @@ -839,6 +842,20 @@ else if (ifBefore.getStatements().size() == 2 && ifAfter.getStatements().size() blockChangeHistory.addChange(blockBefore, blockAfter, ChangeFactory.forBlock(Change.Type.ELSE_BLOCK_REMOVED)); elseChange = true; } + else if (ifBefore.getStatements().size() == 2 && ifAfter.getStatements().size() == 2) { + if(ifBefore.getStatements().get(1).getLocationInfo().getCodeElementType().equals(CodeElementType.BLOCK) && + !ifAfter.getStatements().get(1).getLocationInfo().getCodeElementType().equals(CodeElementType.BLOCK) && + !ifAfter.getStatements().get(1).getLocationInfo().getCodeElementType().equals(CodeElementType.IF_STATEMENT)) { + blockChangeHistory.addChange(blockBefore, blockAfter, ChangeFactory.forBlock(Change.Type.ELSE_BODY_BLOCK_REMOVED)); + elseChange = true; + } + else if(!ifBefore.getStatements().get(1).getLocationInfo().getCodeElementType().equals(CodeElementType.BLOCK) && + !ifBefore.getStatements().get(1).getLocationInfo().getCodeElementType().equals(CodeElementType.IF_STATEMENT) && + ifAfter.getStatements().get(1).getLocationInfo().getCodeElementType().equals(CodeElementType.BLOCK)) { + blockChangeHistory.addChange(blockBefore, blockAfter, ChangeFactory.forBlock(Change.Type.ELSE_BODY_BLOCK_ADDED)); + elseChange = true; + } + } } if (!bodyChange && !catchOrFinallyChange && !elseChange) { if(blockBefore.differInFormatting(blockAfter)) { @@ -891,10 +908,10 @@ private void handleCompositeExpressionChange(Block blockBefore, Block blockAfter addStatementChange(blockBefore, blockAfter, ChangeFactory.forBlock(Change.Type.EXPRESSION_CHANGE)); } if(blockBefore.getComposite().getActualSignature().endsWith("{") && !blockAfter.getComposite().getActualSignature().endsWith("{")) { - addStatementChange(blockBefore, blockAfter, ChangeFactory.forBlock(Change.Type.SIGNATURE_FORMAT_CHANGE)); + addStatementChange(blockBefore, blockAfter, ChangeFactory.forBlock(Change.Type.BLOCK_BODY_REMOVED)); } else if(!blockBefore.getComposite().getActualSignature().endsWith("{") && blockAfter.getComposite().getActualSignature().endsWith("{")) { - addStatementChange(blockBefore, blockAfter, ChangeFactory.forBlock(Change.Type.SIGNATURE_FORMAT_CHANGE)); + addStatementChange(blockBefore, blockAfter, ChangeFactory.forBlock(Change.Type.BLOCK_BODY_ADDED)); } if(blockBefore.differInFormatting(blockAfter)) { addStatementChange(blockBefore, blockAfter, ChangeFactory.forBlock(Change.Type.SIGNATURE_FORMAT_CHANGE)); @@ -1229,12 +1246,12 @@ public HistoryInfo blameReturn(Block startBlock, int exactLineNumber) { boolean multiLine = startBlock.isMultiLine(); for (Change change : historyInfo.getChangeList()) { if (startBlock.isElseBlockStart() || startBlock.isElseBlockEnd()) { - if (change instanceof Introduced || change instanceof ElseBlockAdded) { + if (change instanceof ElseBodyBlockAdded || change instanceof Introduced || change instanceof ElseBlockAdded) { return historyInfo; } } else if (startBlock.isClosingCurlyBracket()) { - if (change instanceof Introduced || change instanceof ReplacePipelineWithLoop) { + if (change instanceof BlockBodyAdded || change instanceof Introduced || change instanceof ReplacePipelineWithLoop) { return historyInfo; } } @@ -1260,7 +1277,7 @@ else if (startBlock.isDoWhileConditional()) { return historyInfo; } } - if (startBlock.getComposite() instanceof CompositeStatementObject && (change instanceof ExpressionChange || change instanceof BlockSignatureFormatChange)) { + if (startBlock.getComposite() instanceof CompositeStatementObject && (change instanceof BlockBodyAdded || change instanceof BlockBodyRemoved || change instanceof ExpressionChange || change instanceof BlockSignatureFormatChange)) { if (multiLine) { if (lineChangeMap.containsKey(pair)) { if (lineChangeMap.get(pair).contains(exactLineNumber)) { diff --git a/src/main/java/org/codetracker/change/Change.java b/src/main/java/org/codetracker/change/Change.java index df77c1cbbc2..7f0843e289e 100644 --- a/src/main/java/org/codetracker/change/Change.java +++ b/src/main/java/org/codetracker/change/Change.java @@ -28,6 +28,10 @@ enum Type { FINALLY_BLOCK_REMOVED("finally block removed"), ELSE_BLOCK_ADDED("else block added"), ELSE_BLOCK_REMOVED("else block removed"), + ELSE_BODY_BLOCK_ADDED("else body block added"), + ELSE_BODY_BLOCK_REMOVED("else body block removed"), + BLOCK_BODY_ADDED("block body added"), + BLOCK_BODY_REMOVED("block body removed"), BLOCK_SPLIT("block split"), BLOCK_MERGE("block merge"), METHOD_SPLIT("method split"), diff --git a/src/main/java/org/codetracker/change/ChangeFactory.java b/src/main/java/org/codetracker/change/ChangeFactory.java index e9e2059381d..e4402fd547b 100644 --- a/src/main/java/org/codetracker/change/ChangeFactory.java +++ b/src/main/java/org/codetracker/change/ChangeFactory.java @@ -165,6 +165,14 @@ public AbstractChange build() { change = new FinallyBlockRemoved(); break; } + case BLOCK_BODY_ADDED: { + change = new BlockBodyAdded(); + break; + } + case BLOCK_BODY_REMOVED: { + change = new BlockBodyRemoved(); + break; + } case ELSE_BLOCK_ADDED: { change = new ElseBlockAdded(); break; @@ -173,6 +181,14 @@ public AbstractChange build() { change = new ElseBlockRemoved(); break; } + case ELSE_BODY_BLOCK_ADDED: { + change = new ElseBodyBlockAdded(); + break; + } + case ELSE_BODY_BLOCK_REMOVED: { + change = new ElseBodyBlockRemoved(); + break; + } case INTERFACE_LIST_CHANGE: { change = new ClassInterfaceListChange(); break; diff --git a/src/main/java/org/codetracker/change/block/BlockBodyAdded.java b/src/main/java/org/codetracker/change/block/BlockBodyAdded.java new file mode 100644 index 00000000000..42a691fb137 --- /dev/null +++ b/src/main/java/org/codetracker/change/block/BlockBodyAdded.java @@ -0,0 +1,15 @@ +package org.codetracker.change.block; + +import org.codetracker.change.Change; + +public class BlockBodyAdded extends BlockChange { + + public BlockBodyAdded() { + super(Change.Type.BLOCK_BODY_ADDED); + } + + @Override + public String toString() { + return "Block Body Added"; + } +} diff --git a/src/main/java/org/codetracker/change/block/BlockBodyRemoved.java b/src/main/java/org/codetracker/change/block/BlockBodyRemoved.java new file mode 100644 index 00000000000..76dc73155a1 --- /dev/null +++ b/src/main/java/org/codetracker/change/block/BlockBodyRemoved.java @@ -0,0 +1,15 @@ +package org.codetracker.change.block; + +import org.codetracker.change.Change; + +public class BlockBodyRemoved extends BlockChange { + + public BlockBodyRemoved() { + super(Change.Type.BLOCK_BODY_REMOVED); + } + + @Override + public String toString() { + return "Block Body Removed"; + } +} diff --git a/src/main/java/org/codetracker/change/block/ElseBodyBlockAdded.java b/src/main/java/org/codetracker/change/block/ElseBodyBlockAdded.java new file mode 100644 index 00000000000..f481abba8f2 --- /dev/null +++ b/src/main/java/org/codetracker/change/block/ElseBodyBlockAdded.java @@ -0,0 +1,14 @@ +package org.codetracker.change.block; + +import org.codetracker.change.Change; + +public class ElseBodyBlockAdded extends BlockChange { + public ElseBodyBlockAdded() { + super(Change.Type.ELSE_BODY_BLOCK_ADDED); + } + + @Override + public String toString() { + return "Else Body Block Added"; + } +} diff --git a/src/main/java/org/codetracker/change/block/ElseBodyBlockRemoved.java b/src/main/java/org/codetracker/change/block/ElseBodyBlockRemoved.java new file mode 100644 index 00000000000..00e17f524c7 --- /dev/null +++ b/src/main/java/org/codetracker/change/block/ElseBodyBlockRemoved.java @@ -0,0 +1,14 @@ +package org.codetracker.change.block; + +import org.codetracker.change.Change; + +public class ElseBodyBlockRemoved extends BlockChange { + public ElseBodyBlockRemoved() { + super(Change.Type.ELSE_BODY_BLOCK_REMOVED); + } + + @Override + public String toString() { + return "Else Body Block Removed"; + } +} diff --git a/src/test/resources/blame/blameTestWithLocalRepo13.txt b/src/test/resources/blame/blameTestWithLocalRepo13.txt index 77e745fe5ca..3d140457009 100644 --- a/src/test/resources/blame/blameTestWithLocalRepo13.txt +++ b/src/test/resources/blame/blameTestWithLocalRepo13.txt @@ -202,27 +202,27 @@ bb1b29851 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocal 9c3b17b9d src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Bhavik Patel 2015-12-26 15:31:51 +0000 202) } 0c717ef2a src/checkstyle/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Rick Giles 2003-09-11 12:01:47 +0000 203) break; 0c717ef2a src/checkstyle/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Rick Giles 2003-09-11 12:01:47 +0000 204) case TokenTypes.PARAMETER_DEF: -f0ed29b5c src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (rnveach 2017-11-09 14:45:31 +0000 205) if (!isInLambda(ast) +4d2e6647f src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Michal Kordas 2015-08-27 19:53:59 +0000 205) if (!isInLambda(ast) f0ed29b5c src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (rnveach 2017-11-09 14:45:31 +0000 206) && ast.findFirstToken(TokenTypes.MODIFIERS) f0ed29b5c src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (rnveach 2017-11-09 14:45:31 +0000 207) .findFirstToken(TokenTypes.FINAL) == null -f0ed29b5c src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (rnveach 2017-11-09 14:45:31 +0000 208) && !isInAbstractOrNativeMethod(ast) -f0ed29b5c src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (rnveach 2017-11-09 14:45:31 +0000 209) && !ScopeUtils.isInInterfaceBlock(ast) -f0ed29b5c src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (rnveach 2017-11-09 14:45:31 +0000 210) && !isMultipleTypeCatch(ast)) { +4d2e6647f src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Michal Kordas 2015-08-27 19:53:59 +0000 208) && !isInAbstractOrNativeMethod(ast) +4d214096f src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (liscju 2016-12-07 21:22:51 +0000 209) && !ScopeUtils.isInInterfaceBlock(ast) +4d214096f src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (liscju 2016-12-07 21:22:51 +0000 210) && !isMultipleTypeCatch(ast)) { 36b91a59d src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Vladislav Lisetskiy 2015-11-01 13:41:29 +0000 211) insertParameter(ast); 62179e05f src/checkstyle/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Rick Giles 2004-07-25 19:11:26 +0000 212) } 0c717ef2a src/checkstyle/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Rick Giles 2003-09-11 12:01:47 +0000 213) break; 0c717ef2a src/checkstyle/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Rick Giles 2003-09-11 12:01:47 +0000 214) case TokenTypes.VARIABLE_DEF: -8fef90609 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (rnveach 2017-07-30 02:50:11 +0000 215) if (ast.getParent().getType() != TokenTypes.OBJBLOCK +1bd30555e src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Michal Kordas 2015-03-10 21:36:38 +0000 215) if (ast.getParent().getType() != TokenTypes.OBJBLOCK 8fef90609 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (rnveach 2017-07-30 02:50:11 +0000 216) && ast.findFirstToken(TokenTypes.MODIFIERS) 8fef90609 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (rnveach 2017-07-30 02:50:11 +0000 217) .findFirstToken(TokenTypes.FINAL) == null -8fef90609 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (rnveach 2017-07-30 02:50:11 +0000 218) && !isVariableInForInit(ast) -8fef90609 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (rnveach 2017-07-30 02:50:11 +0000 219) && shouldCheckEnhancedForLoopVariable(ast)) { +b097b3f00 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Baratali Izmailov 2015-08-03 01:27:52 +0000 218) && !isVariableInForInit(ast) +36b91a59d src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Vladislav Lisetskiy 2015-11-01 13:41:29 +0000 219) && shouldCheckEnhancedForLoopVariable(ast)) { bb1b29851 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (alexkravin 2015-01-19 14:20:14 +0000 220) insertVariable(ast); 0c717ef2a src/checkstyle/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Rick Giles 2003-09-11 12:01:47 +0000 221) } 0c717ef2a src/checkstyle/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Rick Giles 2003-09-11 12:01:47 +0000 222) break; 0c717ef2a src/checkstyle/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Rick Giles 2003-09-11 12:01:47 +0000 223) case TokenTypes.IDENT: bb1b29851 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (alexkravin 2015-01-19 14:20:14 +0000 224) final int parentType = ast.getParent().getType(); -36b91a59d src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Vladislav Lisetskiy 2015-11-01 13:41:29 +0000 225) if (isAssignOperator(parentType) && isFirstChild(ast)) { +bf69cf167 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Andrei Selkin 2016-03-29 22:47:32 +0000 225) if (isAssignOperator(parentType) && isFirstChild(ast)) { bf69cf167 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Andrei Selkin 2016-03-29 22:47:32 +0000 226) final Optional candidate = getFinalCandidate(ast); bf69cf167 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Andrei Selkin 2016-03-29 22:47:32 +0000 227) if (candidate.isPresent()) { ed76401d3 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Andrei Selkin 2016-07-23 05:09:29 +0000 228) determineAssignmentConditions(ast, candidate.get()); @@ -254,7 +254,7 @@ bb1b29851 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocal 3b531fe99 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Pavel Bludov 2017-12-24 05:13:50 +0000 254) final Deque prevScopeUninitializedVariableData = 628e893f2 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Bhavik Patel 2016-01-24 14:35:35 +0000 255) prevScopeUninitializedVariables.peek(); 5e0ab7577 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Luolc 2017-04-18 19:54:05 +0000 256) boolean containsBreak = false; -628e893f2 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Bhavik Patel 2016-01-24 14:35:35 +0000 257) if (ast.getParent().getType() != TokenTypes.CASE_GROUP +9c3b17b9d src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Bhavik Patel 2015-12-26 15:31:51 +0000 257) if (ast.getParent().getType() != TokenTypes.CASE_GROUP 628e893f2 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Bhavik Patel 2016-01-24 14:35:35 +0000 258) || findLastChildWhichContainsSpecifiedToken(ast.getParent().getParent(), 628e893f2 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Bhavik Patel 2016-01-24 14:35:35 +0000 259) TokenTypes.CASE_GROUP, TokenTypes.SLIST) == ast.getParent()) { 5e0ab7577 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Luolc 2017-04-18 19:54:05 +0000 260) containsBreak = scopeStack.peek().containsBreak; @@ -384,8 +384,8 @@ bf69cf167 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocal 55aa50d8f src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Andrei Selkin 2016-03-29 22:47:31 +0000 384) if (candidate != null) { 55aa50d8f src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Andrei Selkin 2016-03-29 22:47:31 +0000 385) storedVariable = candidate.variableIdent; 55aa50d8f src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Andrei Selkin 2016-03-29 22:47:31 +0000 386) } -5e0ab7577 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Luolc 2017-04-18 19:54:05 +0000 387) if (storedVariable != null -5e0ab7577 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Luolc 2017-04-18 19:54:05 +0000 388) && isSameVariables(storedVariable, variable) +628e893f2 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Bhavik Patel 2016-01-24 14:35:35 +0000 387) if (storedVariable != null +628e893f2 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Bhavik Patel 2016-01-24 14:35:35 +0000 388) && isSameVariables(storedVariable, variable) 5e0ab7577 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Luolc 2017-04-18 19:54:05 +0000 389) && isSameVariables(assignedVariable, variable)) { 628e893f2 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Bhavik Patel 2016-01-24 14:35:35 +0000 390) scopeData.uninitializedVariables.push(variable); 5e0ab7577 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Luolc 2017-04-18 19:54:05 +0000 391) iterator.remove(); @@ -545,7 +545,7 @@ bf69cf167 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocal 36b91a59d src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Vladislav Lisetskiy 2015-11-01 13:41:29 +0000 545) // if the variable is declared outside the loop and initialized inside 36b91a59d src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Vladislav Lisetskiy 2015-11-01 13:41:29 +0000 546) // the loop, then it cannot be declared final, as it can be initialized 36b91a59d src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Vladislav Lisetskiy 2015-11-01 13:41:29 +0000 547) // more than once in this case -11210350f src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Andrei Selkin 2016-03-29 22:47:31 +0000 548) if (isInTheSameLoop(variable, ast) || !isUseOfExternalVariableInsideLoop(ast)) { +bf69cf167 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Andrei Selkin 2016-03-29 22:47:32 +0000 548) if (isInTheSameLoop(variable, ast) || !isUseOfExternalVariableInsideLoop(ast)) { bf69cf167 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Andrei Selkin 2016-03-29 22:47:32 +0000 549) final FinalVariableCandidate candidate = scopeData.scope.get(ast.getText()); ed76401d3 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Andrei Selkin 2016-07-23 05:09:29 +0000 550) shouldRemove = candidate.alreadyAssigned; 36b91a59d src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Vladislav Lisetskiy 2015-11-01 13:41:29 +0000 551) } @@ -640,10 +640,10 @@ dfef8ec6d src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocal 11ff590ba src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Bhavik Patel 2015-06-18 21:42:16 +0000 640) */ 36b91a59d src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Vladislav Lisetskiy 2015-11-01 13:41:29 +0000 641) private static DetailAST findFirstUpperNamedBlock(DetailAST ast) { 11ff590ba src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Bhavik Patel 2015-06-18 21:42:16 +0000 642) DetailAST astTraverse = ast; -e79f94539 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (rnveach 2016-05-03 01:46:00 +0000 643) while (astTraverse.getType() != TokenTypes.METHOD_DEF -e79f94539 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (rnveach 2016-05-03 01:46:00 +0000 644) && astTraverse.getType() != TokenTypes.CLASS_DEF -e79f94539 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (rnveach 2016-05-03 01:46:00 +0000 645) && astTraverse.getType() != TokenTypes.ENUM_DEF -e79f94539 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (rnveach 2016-05-03 01:46:00 +0000 646) && astTraverse.getType() != TokenTypes.CTOR_DEF +36b91a59d src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Vladislav Lisetskiy 2015-11-01 13:41:29 +0000 643) while (astTraverse.getType() != TokenTypes.METHOD_DEF +36b91a59d src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Vladislav Lisetskiy 2015-11-01 13:41:29 +0000 644) && astTraverse.getType() != TokenTypes.CLASS_DEF +36b91a59d src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Vladislav Lisetskiy 2015-11-01 13:41:29 +0000 645) && astTraverse.getType() != TokenTypes.ENUM_DEF +dfef8ec6d src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (rnveach 2016-05-01 12:37:07 +0000 646) && astTraverse.getType() != TokenTypes.CTOR_DEF e79f94539 src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (rnveach 2016-05-03 01:46:00 +0000 647) && !ScopeUtils.isClassFieldDef(astTraverse)) { 11ff590ba src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Bhavik Patel 2015-06-18 21:42:16 +0000 648) astTraverse = astTraverse.getParent(); 11ff590ba src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java (Bhavik Patel 2015-06-18 21:42:16 +0000 649) } diff --git a/src/test/resources/blame/blameTestWithLocalRepo15.txt b/src/test/resources/blame/blameTestWithLocalRepo15.txt index bd45822584a..91809811eab 100644 --- a/src/test/resources/blame/blameTestWithLocalRepo15.txt +++ b/src/test/resources/blame/blameTestWithLocalRepo15.txt @@ -222,7 +222,7 @@ df8581759 src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java ( 222) 82118e728 src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (Dmitry Baev 2015-05-21 11:27:27 +0000 223) if (computeTestMethods().isEmpty()) { 5d957024b src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (dsaff 2008-07-30 19:23:24 +0000 224) errors.add(new Exception("No runnable methods")); -5d957024b src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (dsaff 2008-07-30 19:23:24 +0000 225) } +bb91daf8e src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (Kevin Cooney 2012-10-24 19:31:00 +0000 225) } 5d957024b src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (dsaff 2008-07-30 19:23:24 +0000 226) } 227) cbf46b88c src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (Jeremy Herault 2012-08-17 12:56:22 +0000 228) protected void validateFields(List errors) { @@ -438,17 +438,17 @@ aad22b88b src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java ( a49240ade src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (Kevin Cooney 2011-01-12 05:06:08 +0000 438) } 439) 96d7dd609 src/main/java/org/junit/internal/runners/model/TestAnnotation.java (kbeck 2008-07-01 18:29:54 +0000 440) private Class getExpectedException(Test annotation) { -96d7dd609 src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (kbeck 2008-07-01 18:29:54 +0000 441) if (annotation == null || annotation.expected() == None.class) { +bb91daf8e src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (Kevin Cooney 2012-10-24 19:31:00 +0000 441) if (annotation == null || annotation.expected() == None.class) { 96d7dd609 src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (kbeck 2008-07-01 18:29:54 +0000 442) return null; -96d7dd609 src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (kbeck 2008-07-01 18:29:54 +0000 443) } else { +bb91daf8e src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (Kevin Cooney 2012-10-24 19:31:00 +0000 443) } else { 96d7dd609 src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (kbeck 2008-07-01 18:29:54 +0000 444) return annotation.expected(); -96d7dd609 src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (kbeck 2008-07-01 18:29:54 +0000 445) } +bb91daf8e src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (Kevin Cooney 2012-10-24 19:31:00 +0000 445) } 96d7dd609 src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (kbeck 2008-07-01 18:29:54 +0000 446) } 447) 96d7dd609 src/main/java/org/junit/internal/runners/model/TestAnnotation.java (kbeck 2008-07-01 18:29:54 +0000 448) private long getTimeout(Test annotation) { -96d7dd609 src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (kbeck 2008-07-01 18:29:54 +0000 449) if (annotation == null) { +bb91daf8e src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (Kevin Cooney 2012-10-24 19:31:00 +0000 449) if (annotation == null) { 96d7dd609 src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (kbeck 2008-07-01 18:29:54 +0000 450) return 0; -96d7dd609 src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (kbeck 2008-07-01 18:29:54 +0000 451) } +bb91daf8e src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (Kevin Cooney 2012-10-24 19:31:00 +0000 451) } 96d7dd609 src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (kbeck 2008-07-01 18:29:54 +0000 452) return annotation.timeout(); 96d7dd609 src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java (kbeck 2008-07-01 18:29:54 +0000 453) } 454)