diff options
-rw-r--r-- | src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/CatchParameterNameCheck.java | 21 | ||||
-rw-r--r-- | src/xdocs/config_naming.xml | 20 |
2 files changed, 40 insertions, 1 deletions
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: * </p> + * <p>Configuration:</p> * <pre> * <module name="CatchParameterName"> * <property name="format" value="^[a-z][a-zA-Z0-9]+$"/> * </module> * </pre> - * + * <p>Example:</p> + * <pre> + * 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 + * // ... + * } + * } + * } + * </pre> * @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: </p> + <p>Configuration:</p> <source> <module name="CatchParameterName"> <property name="format" value="^[a-z][a-zA-Z0-9]+$"/> </module> </source> + <p>Example:</p> + <pre> +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 + // ... + } + } +} + </pre> </subsection> <subsection name="Example of Usage" id="CatchParameterName_Example_of_Usage"> |