Rule Set:
<rule ref="rulesets/java/empty.xml"/>
Description:
Code Sample demonstrating the issue:
@RunWith(RobolectricTestRunner.class) public class MyTestClass { @Rule public final MockitoRule mockitoRule = MockitoJUnit.rule().strictness(STRICT_STUBS); @Mock private WebView webView; private HomeActivity activity; @Test public void onSaveInstanceState() { final Bundle bundle = new Bundle(); try { activity.onSaveInstanceState(bundle); fail(); } catch (NullPointerException ignore) { // This is expected when testing with Robolectric. } verify(webView).saveState(bundle); } }
I'd expect this to not get flagged by PMD if the exception name is ignore
or expected
. Instead it'll be:
<violation beginline="30" endline="32" begincolumn="7" endcolumn="5" rule="EmptyCatchBlock" ruleset="Empty Code" package="com.coyoapp.mobile.main.feature.home" class="MyTestClass" method="onSaveInstanceState" externalInfoUrl="https://pmd.github.io/pmd-5.6.1/pmd-java/rules/java/empty.html#EmptyCatchBlock" priority="3"> Avoid empty catch blocks </violation>
Especially if the catch branch has a comment.
Running PMD through: Gradle
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