Affects PMD Version: 6.45.0
Rule: EmptyCatchBlock
Description: The current implementation ignores formal comments when the option allowCommentedBlocks
is used. Only single line comments or multi line comments, which are not doc comments, are considered. Therefore, if there is only a doc comment in the catch block, it is considered to be empty and is reported - despite the fact, that here is a comment and the block is not empty.
This might be a false positive.
However, current test cases explicitly verify this case as being reported.
Overall, this might be a contrived example...
Background: the behaviour of this rule might be changed in pmd7 with #3893
Code Sample demonstrating the issue:
@IsTest private class FunctionalityTest { static testMethod void testWithModifier() { try { } catch (Exception e) { // line 5 /** NOK: doc comment inside of empty catch block; should be reported */ } }
Complete test cases:
Expected outcome:
PMD should not report a violation at line 5. This is a false-positive.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4