1
2
3
4
5
6
7
8
9
10
11
12
13
14 package com.puppycrawl.tools.checkstyle.checks.coding.unnecessaryparentheses;
15 public class InputUnnecessaryParenthesesOperatorsAndCasts {
16 int f1() {
17 int x = 0;
18 for (int i = (0+1); ((i) < (6+6)); i += (1+0)) {
19 x += (i + 100);
20 (x) += (i + 100);
21 x = (x + i + 100);
22 (x) = (x + i + 100);
23 }
24
25 for (int i = (0+1); (i) < ((6+6)); i += (1+0)) {
26 System.identityHashCode("hi");
27 }
28
29 return (0);
30 }
31
32 private int f2(int arg1, double arg2) {
33 int x, a, b, c, d;
34 String e, f;
35
36 x = 0;
37 a = 0;
38 b = 0;
39 c = (a + b);
40 d = c - 1;
41
42 int i = (int) arg2;
43 i = ((int) arg2);
44
45 x += (i + 100 + arg1);
46 a = (a + b) * (c + d);
47 b = ((((a + b) * (c + d))));
48 c = (((a) <= b)) ? 0 : 1;
49 d = (a) + (b) * (600) / (int) (12.5f) + (int) (arg2);
50 e = ("this") + ("that") + ("is" + "other");
51 f = ("this is a really, really long string that should be truncated.");
52
53 return (x + a + b + d);
54 }
55
56 private boolean f3() {
57 int x = f2((1), (13.5));
58 boolean b = (true);
59 return (b);
60 }
61
62 public static int f4(int z, int a) {
63 int r = (z * a);
64 r = (a > z) ? a : z;
65 r = ((a > z) ? a : z);
66 r = (a > z) ? a : (z + z);
67 return (r * r - 1);
68 }
69
70 public void f5() {
71 int x, y;
72 x = 0;
73 y = 0;
74 if (x == y) {
75 print(x);
76 }
77 if ((x > y)) {
78 print(y);
79 }
80
81 while ((x < 10)) {
82 print(x++);
83 }
84
85 do {
86 print((y+=100));
87 } while (y < (4000));
88 }
89
90 private void f6(TypeA a) {
91 TypeB b = (TypeB) a;
92 TypeC c = ((TypeC) a);
93 int r = 12345;
94 r <<= (3);
95 GenT<String> d = ((GenT<String>) a);
96 }
97
98 private void print(int arg)
99 {
100 System.identityHashCode("arg = " + arg);
101 }
102
103 private int f7() {
104 String f;
105
106 f = ("12345678901234567890123");
107
108 return 0;
109 }
110
111 static class GenT<T> {}
112 static class TypeA extends GenT<String> {}
113 static class TypeB extends TypeA {}
114 static class TypeC extends TypeA {}
115 }