View Javadoc
1   /*xml
2   <module name="Checker">
3     <module name="TreeWalker">
4       <module name="ParameterAssignment"/>
5     </module>
6   </module>
7   */
8   
9   package com.puppycrawl.tools.checkstyle.checks.coding.parameterassignment;
10  
11  
12  import java.util.function.IntBinaryOperator;
13  import java.util.function.IntPredicate;
14  
15  // xdoc section -- start
16  class Example1 {
17    int methodOne(int parameter) {
18      if (parameter <= 0 ) {
19        throw new IllegalArgumentException("A positive value is expected");
20      }
21      // violation below 'Assignment of parameter 'parameter' is not allowed.'
22      parameter -= 2;
23      return parameter;
24    }
25  
26    int methodTwo(int parameter) {
27      if (parameter <= 0 ) {
28        throw new IllegalArgumentException("A positive value is expected");
29      }
30      int local = parameter;
31      local -= 2;
32      return local;
33    }
34    // violation below 'Assignment of parameter 'a' is not allowed.'
35    IntPredicate obj = a -> ++a == 12;
36    IntBinaryOperator obj2 = (int a, int b) -> {
37      a++;     // violation 'Assignment of parameter 'a' is not allowed.'
38      b += 12; // violation 'Assignment of parameter 'b' is not allowed.'
39      return a + b;
40    };
41    IntPredicate obj3 = a -> {
42      int b = a;
43      return ++b == 12;
44    };
45  }
46  // xdoc section -- end