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] 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