1
2
3
4
5
6
7 package com.puppycrawl.tools.checkstyle.checks.coding.parameterassignment;
8
9 import javax.annotation.Nullable;
10
11 public class InputParameterAssignmentWithUnchecked {
12 int field;
13 void foo1(int field) {
14 int i = field;
15 this.field = field;
16 i++;
17 field = 0;
18 field += 1;
19 this.field++;
20 field--;
21 }
22
23 void foo2() {
24 field = 0;
25 }
26 @SuppressWarnings(value = "unchecked")
27 void foo3(String field, int field1) {
28 this.field = (field1 += field.length());
29 }
30
31 void foo4() {
32 String hidden = "";
33 new NestedClass() {
34 public void test(String hidden) {
35 }
36 };
37 hidden += "test";
38 }
39
40
41 void foo5(int EXPR) {
42 int i = EXPR;
43 }
44
45 SomeInterface obj = q -> q++;
46 SomeInterface obj2 = (int q) -> q += 12;
47 SomeInterface obj3 = (w) -> w--;
48 AnotherInterface obj4 = (int q, int w) -> obj.equals(obj2);
49 AnotherInterface obj5 = (q, w) -> w = 14;
50 SomeInterface obj6 = (@Nullable int a) -> a += 12;
51 AnotherInterface obj7 = (@Nullable int c, @Nullable int d) -> {
52 c += d;
53 d += c;
54 };
55
56 void method() {
57 int q = 12;
58 SomeInterface obj = (d) -> {
59 SomeInterface b = (c) -> obj2.equals(obj4);
60 int c = 12;
61 c++;
62 SomeInterface r = (field) -> this.field++;
63 d -= 10;
64 };
65 }
66
67 public static abstract class NestedClass {
68 public abstract void test(String hidden);
69 }
70
71 public interface SomeInterface {
72 void method(int a);
73 }
74
75 public interface AnotherInterface {
76 void method(int a, int b);
77 }
78 }