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 + } + } } ]]> diff --git a/src/site/markdown/overview/changelog.md b/src/site/markdown/overview/changelog.md index ebbddd4ca5..e009569260 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-logging: