A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/432 below:

false positive for empty try-with-resource · Issue #432 · pmd/pmd · GitHub

Rule Set:

rulesets/java/empty.xml/EmptyTryBlock

Description:

The rule says "Avoid empty try blocks - what's the point?". I believe an exception should be made for empty try-with-resource blocks, as this is a valid use case.

Code Sample demonstrating the issue:

class X {
	void method() {
		try {
			// true positive
		} catch (Exception e) {
		}

		try (ClientResponse response = execute(() -> target.request(mediaTypes).delete(), DELETE, new ExpectedResponse(status, required))) {
			// false positive
		}
	}
}

Running PMD through: CLI

pmd.bat -d X.java -f xml -R rulesets/java/empty.xml/EmptyTryBlock

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