From 223b4e6efe089325e5ad1ca492828579feea56d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Thu, 6 May 2021 14:05:59 +0200 Subject: [PATCH 1/3] Improve doc of SwitchStmtsShouldHaveDefault, fix #2737 --- .../main/resources/category/java/bestpractices.xml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pmd-java/src/main/resources/category/java/bestpractices.xml b/pmd-java/src/main/resources/category/java/bestpractices.xml index e8c1f71d4c..bf2711c373 100644 --- a/pmd-java/src/main/resources/category/java/bestpractices.xml +++ b/pmd-java/src/main/resources/category/java/bestpractices.xml @@ -1287,12 +1287,15 @@ public class Foo { -All switch statements should include a default option to catch any unspecified values. + Switch statements should be exhaustive, to make their control flow + easier to follow. This can be achieved by addinga `default` case, or, + if the switch is on an enum type, by ensuring there is one switch branch + for each enum constant. 3 @@ -1305,14 +1308,14 @@ All switch statements should include a default option to catch any unspecified v From 07141d87c3555730b9a3c80989ae372746d56980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Thu, 6 May 2021 14:07:20 +0200 Subject: [PATCH 2/3] Release notes --- docs/pages/release_notes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 8fbc39c87b..0837043a34 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -18,6 +18,8 @@ This is a {{ site.pmd.release_type }} release. * doc * [#3230](https://github.com/pmd/pmd/issues/3230): \[doc] Remove "Edit me" button for language index pages +* java-bestpractices + * [#2737](https://github.com/pmd/pmd/issues/2737): \[java] Fix misleading rule message on rule SwitchStmtsShouldHaveDefault with non-exhaustive enum switch * java-codestyle * [#2655](https://github.com/pmd/pmd/issues/2655): \[java] UnnecessaryImport false positive for on-demand imports From 6c9ae9b8374a157d0ef8db4706f9fca012de2dd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Thu, 6 May 2021 14:08:39 +0200 Subject: [PATCH 3/3] Typo --- pmd-java/src/main/resources/category/java/bestpractices.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmd-java/src/main/resources/category/java/bestpractices.xml b/pmd-java/src/main/resources/category/java/bestpractices.xml index bf2711c373..7315700fc2 100644 --- a/pmd-java/src/main/resources/category/java/bestpractices.xml +++ b/pmd-java/src/main/resources/category/java/bestpractices.xml @@ -1293,7 +1293,7 @@ public class Foo { externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#switchstmtsshouldhavedefault"> Switch statements should be exhaustive, to make their control flow - easier to follow. This can be achieved by addinga `default` case, or, + easier to follow. This can be achieved by adding a `default` case, or, if the switch is on an enum type, by ensuring there is one switch branch for each enum constant.