From 60043f484dbea4d655286d07bab5b2406bde5650 Mon Sep 17 00:00:00 2001 From: AkMo3 Date: Wed, 24 Feb 2021 19:26:40 +0530 Subject: [PATCH] Issue #7655: Update doc for ParameterAssignment --- .../coding/ParameterAssignmentCheck.java | 23 +++++++++++++++++++ src/xdocs/config_coding.xml | 23 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheck.java index 4e14cd79c46..94e1e41de6b 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheck.java @@ -50,6 +50,29 @@ * <module name="ParameterAssignment"/> * *

+ * Example: + *

+ *
+ * class MyClass {
+ *   int methodOne(int parameter) {
+ *     if (parameter <= 0 ) {
+ *       throw new IllegalArgumentException("A positive value is expected");
+ *     }
+ *     parameter -= 2;  // violation
+ *     return parameter;
+ *   }
+ *
+ *   int methodTwo(int parameter) {
+ *     if (parameter <= 0 ) {
+ *       throw new IllegalArgumentException("A positive value is expected");
+ *     }
+ *     int local = parameter;
+ *     local -= 2;  // OK
+ *     return local;
+ *   }
+ * }
+ * 
+ *

* Parent is {@code com.puppycrawl.tools.checkstyle.TreeWalker} *

*

diff --git a/src/xdocs/config_coding.xml b/src/xdocs/config_coding.xml index 4266f8fce57..873767c1b79 100644 --- a/src/xdocs/config_coding.xml +++ b/src/xdocs/config_coding.xml @@ -5836,6 +5836,29 @@ public class AnnotationLocationCheck extends AbstractCheck { <module name="ParameterAssignment"/> +

+ Example: +

+ +class MyClass { + int methodOne(int parameter) { + if (parameter <= 0 ) { + throw new IllegalArgumentException("A positive value is expected"); + } + parameter -= 2; // violation + return parameter; + } + + int methodTwo(int parameter) { + if (parameter <= 0 ) { + throw new IllegalArgumentException("A positive value is expected"); + } + int local = parameter; + local -= 2; // OK + return local; + } +} +