From 27512b0acc3ad3cb4e28306d4f8936b9108c5bca Mon Sep 17 00:00:00 2001 From: jack870131 Date: Wed, 19 Sep 2018 22:16:36 +0100 Subject: Issue #5832: Add javadoc and xdoc Example for CatchParameterName --- .../checks/naming/CatchParameterNameCheck.java | 21 ++++++++++++++++++++- src/xdocs/config_naming.xml | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/CatchParameterNameCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/CatchParameterNameCheck.java index 9871c01ac..e3530fe13 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/CatchParameterNameCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/CatchParameterNameCheck.java @@ -56,12 +56,31 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; * An example of how to configure the check for names that begin with a lower case letter, * followed by any letters or digits is: *

+ *

Configuration:

*
  * <module name="CatchParameterName">
  *   <property name="format" value="^[a-z][a-zA-Z0-9]+$"/>
  * </module>
  * 
- * + *

Example:

+ *
+ * public class MyTest {
+ *   public void myTest() {
+ *     try {
+ *       // ...
+ *     } catch (ArithmeticException ex) { //OK
+ *       // ...
+ *     } catch (ArrayIndexOutOfBoundsException ex2) { //OK
+ *       // ...
+ *     } catch (IOException thirdException) { //OK
+ *       // ...
+ *     } catch (Exception FourthException) { // violation, the initial letter
+ *                                           // should be lowercase
+ *       // ...
+ *     }
+ *   }
+ * }
+ * 
* @since 6.14 */ public class CatchParameterNameCheck extends AbstractNameCheck { diff --git a/src/xdocs/config_naming.xml b/src/xdocs/config_naming.xml index ec6ea1ced..71bd1edbb 100644 --- a/src/xdocs/config_naming.xml +++ b/src/xdocs/config_naming.xml @@ -376,11 +376,31 @@ class AbstractThirdClass {} // OK, no "abstract" modifier An example of how to configure the check for names that begin with a lower case letter, followed by any letters or digits is:

+

Configuration:

<module name="CatchParameterName"> <property name="format" value="^[a-z][a-zA-Z0-9]+$"/> </module> +

Example:

+
+public class MyTest {
+  public void myTest() {
+    try {
+      // ...
+    } catch (ArithmeticException ex) { //OK
+      // ...
+    } catch (ArrayIndexOutOfBoundsException ex2) { //OK
+      // ...
+    } catch (IOException thirdException) { //OK
+      // ...
+    } catch (Exception FourthException) { // violation, the initial letter
+                                          // should be lowercase
+      // ...
+    }
+  }
+}
+        
-- cgit v1.2.3