From 878f73158a76fed252d1d048767b9cbeea28857d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Wed, 21 Jun 2017 17:20:11 -0300 Subject: [PATCH 1/2] [java] Allow try-with-resources to be empty * Fixes #432 --- pmd-java/src/main/resources/rulesets/java/empty.xml | 2 +- .../pmd/lang/java/rule/empty/xml/EmptyTryBlock.xml | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pmd-java/src/main/resources/rulesets/java/empty.xml b/pmd-java/src/main/resources/rulesets/java/empty.xml index 7141ed3fc2..aa2765ea61 100644 --- a/pmd-java/src/main/resources/rulesets/java/empty.xml +++ b/pmd-java/src/main/resources/rulesets/java/empty.xml @@ -129,7 +129,7 @@ Avoid empty try blocks - what's the point? diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/empty/xml/EmptyTryBlock.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/empty/xml/EmptyTryBlock.xml index c671f1d1c0..8e4a64079e 100644 --- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/empty/xml/EmptyTryBlock.xml +++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/empty/xml/EmptyTryBlock.xml @@ -46,6 +46,19 @@ public class EmptyTryBlock3 { int x = 5; } } +} + ]]> + + + #432 false positive for empty try-with-resource + 0 + target.request(mediaTypes).delete(), DELETE, new ExpectedResponse(status, required))) { + // false positive + } + } } ]]> From 7ffa76e3e232f38a2dfc645f0d364b186ce48ef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Wed, 21 Jun 2017 17:27:26 -0300 Subject: [PATCH 2/2] Update changelog, refs #432 --- src/site/markdown/overview/changelog.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/site/markdown/overview/changelog.md b/src/site/markdown/overview/changelog.md index e54f761ecf..368b950e13 100644 --- a/src/site/markdown/overview/changelog.md +++ b/src/site/markdown/overview/changelog.md @@ -39,6 +39,8 @@ Fields using generics are still Work in Progress, but we expect to fully support * The ruleset java-junit now properly detects JUnit5, and rules are being adapted to the changes on it's API. This support is, however, still incomplete. Let us know of any uses we are still missing on the [issue tracker](https://github.com/pmd/pmd/issues) +* The Java rule `EmptyTryBlock` (ruleset java-empty) now allows empty blocks when usin try-with-resources. + ### Fixed Issues * General @@ -57,8 +59,10 @@ Fields using generics are still Work in Progress, but we expect to fully support * [#397](https://github.com/pmd/pmd/issues/397): \[java] ConstructorCallsOverridableMethodRule: false positive for method called from lambda expression * [#410](https://github.com/pmd/pmd/issues/410): \[java] ImmutableField: False positive with lombok * [#422](https://github.com/pmd/pmd/issues/422): \[java] PreserveStackTraceRule: false positive when using builder pattern +* java-empty + * [#432](https://github.com/pmd/pmd/issues/432): \[java] EmptyTryBlock: false positive for empty try-with-resource * java-imports: - * [#348]((https://github.com/pmd/pmd/issues/348): \[java] imports/UnusedImport rule not considering static inner classes of imports + * [#348](https://github.com/pmd/pmd/issues/348): \[java] imports/UnusedImport rule not considering static inner classes of imports * java-junit * [#428](https://github.com/pmd/pmd/issues/428): \[java] PMD requires public modifier on JUnit 5 test * java-unnecessary