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
29 this.field = (field1 += field.length());
30 }
31
32 void foo4() {
33 String hidden = "";
34 new NestedClass() {
35 public void test(String hidden) {
36 }
37 };
38 hidden += "test";
39 }
40
41
42 void foo5(int EXPR) {
43 int i = EXPR;
44 }
45
46 SomeInterface obj = q -> q++;
47
48
49 SomeInterface obj2 = (int q) -> q += 12;
50
51 SomeInterface obj3 = (w) -> w--;
52
53 AnotherInterface obj4 = (int q, int w) -> obj.equals(obj2);
54
55
56 AnotherInterface obj5 = (q, w) -> w = 14;
57
58
59 SomeInterface obj6 = (@Nullable int a) -> a += 12;
60
61 AnotherInterface obj7 = (@Nullable int c, @Nullable int d) -> {
62 c += d;
63 d += c;
64 };
65
66 void method() {
67 int q = 12;
68 SomeInterface obj = (d) -> {
69 SomeInterface b = (c) -> obj2.equals(obj4);
70 int c = 12;
71 c++;
72 SomeInterface r = (field) -> this.field++;
73 d -= 10;
74 };
75 }
76
77 public static abstract class NestedClass {
78 public abstract void test(String hidden);
79 }
80
81 public interface SomeInterface {
82 void method(int a);
83 }
84
85 public interface AnotherInterface {
86 void method(int a, int b);
87 }
88 }