Skip to content

Commit

Permalink
Issue #7655: Update doc for ParameterAssignment
Browse files Browse the repository at this point in the history
  • Loading branch information
AkMo3 authored and rnveach committed Feb 26, 2021
1 parent bea36f9 commit 60043f4
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,29 @@
* <module name="ParameterAssignment"/>
* </pre>
* <p>
* Example:
* </p>
* <pre>
* class MyClass {
* int methodOne(int parameter) {
* if (parameter &lt;= 0 ) {
* throw new IllegalArgumentException("A positive value is expected");
* }
* parameter -= 2; // violation
* return parameter;
* }
*
* int methodTwo(int parameter) {
* if (parameter &lt;= 0 ) {
* throw new IllegalArgumentException("A positive value is expected");
* }
* int local = parameter;
* local -= 2; // OK
* return local;
* }
* }
* </pre>
* <p>
* Parent is {@code com.puppycrawl.tools.checkstyle.TreeWalker}
* </p>
* <p>
Expand Down
23 changes: 23 additions & 0 deletions src/xdocs/config_coding.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5836,6 +5836,29 @@ public class AnnotationLocationCheck extends AbstractCheck {
<source>
&lt;module name=&quot;ParameterAssignment&quot;/&gt;
</source>
<p>
Example:
</p>
<source>
class MyClass {
int methodOne(int parameter) {
if (parameter &lt;= 0 ) {
throw new IllegalArgumentException("A positive value is expected");
}
parameter -= 2; // violation
return parameter;
}

int methodTwo(int parameter) {
if (parameter &lt;= 0 ) {
throw new IllegalArgumentException("A positive value is expected");
}
int local = parameter;
local -= 2; // OK
return local;
}
}
</source>
</subsection>

<subsection name="Example of Usage" id="ParameterAssignment_Example_of_Usage">
Expand Down

0 comments on commit 60043f4

Please sign in to comment.