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      parameter -= 2;  // violation
22      return parameter;
23    }
24  
25    int methodTwo(int parameter) {
26      if (parameter <= 0 ) {
27        throw new IllegalArgumentException("A positive value is expected");
28      }
29      int local = parameter;
30      local -= 2;  // OK
31      return local;
32    }
33  
34    IntPredicate obj = a -> ++a == 12; // violation
35    IntBinaryOperator obj2 = (int a, int b) -> {
36      a++;     // violation
37      b += 12; // violation
38      return a + b;
39    };
40    IntPredicate obj3 = a -> {
41      int b = a; // ok
42      return ++b == 12;
43    };
44  }
45  // xdoc section -- end