forked from checkstyle/checkstyle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InputParenPad.java
223 lines (197 loc) · 6.93 KB
/
InputParenPad.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
package com.google.checkstyle.test.chapter4formatting.rule462horizontalwhitespace;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
public class InputParenPad
{
class ParenPadNoSpace {
ParenPadNoSpace() {
this(0);
}
ParenPadNoSpace(int i) {
super();
}
@SuppressWarnings("")
void method(boolean status) {
try (Writer writer = new StringWriter()) {
do {
writer.append("a");
} while (status);
} catch (IOException e) {
while (status) {
for (int i = 0; i < (long) (2 * (4 / 2)); i++) {
if (i > 2) {
synchronized (this) {
switch (i) {
case 3:
case (4):
case 5:
break;
}
}
}
}
}
}
}
}
class ParenPadSpaceLeft {
ParenPadSpaceLeft( ) { // warning
this( 0); // warning
}
ParenPadSpaceLeft( int i) { // warning
super( ); // warning
}
@SuppressWarnings( "") // warning
void method( boolean status) { // warning
try ( Writer writer = new StringWriter( )) { // warning
do {
writer.append("a");
} while ( status); // warning
} catch ( IOException e) { // warning
while ( status) { // warning
for ( int i = 0; i < ( long) ( 2 * ( 4 / 2)); i++) { // warning
if ( i > 2) { // warning
synchronized ( this) { // warning
switch ( i) { // warning
case 3:
case ( 4): // warning
case 5:
break;
}
}
}
}
}
}
}
}
class ParenPadSpaceRight {
ParenPadSpaceRight( ) { // warning
this(0 ); // warning
}
ParenPadSpaceRight(int i ) { // warning
super( ); // warning
}
@SuppressWarnings("" ) // warning
void method(boolean status ) { // warning
try (Writer writer = new StringWriter( ) ) { // warning
do {
writer.append("a" ); // warning
} while (status ); // warning
} catch (IOException e ) { // warning
while (status ) { // warning
for (int i = 0; i < (long ) (2 * (4 / 2 ) ); i++ ) { // warning
if (i > 2 ) { // warning
synchronized (this ) { // warning
switch (i ) { // warning
case 3:
case (4 ): // warning
case 5:
break;
}
}
}
}
}
}
}
}
String foo() {
return ( (Object // warning
) bar( ( 1 > 2 ) ? // warning
( ( 3 < 4 )? false : true ) : // warning
( ( 1 == 1 ) ? false : true) ) ).toString(); // warning
}
@MyAnnotation
public boolean bar(boolean a) {
assert ( true ); // warning
return true;
}
boolean fooo = this.bar(( true && false ) && true); // warning
}
@interface MyAnnotation {
String someField( ) default "Hello world"; // warning
}
enum MyEnum {
SOME_CONSTANT( ) { // warning
int i = (int) (2 * (4 / 2)
);
};
public void myMethod() {
String s = "test";
Object o = s;
((String)o).length();
( (String)o ).length(); // warning
}
public void crisRon() {
Object leo = "messi";
Object ibra = leo;
((String)leo).compareTo( (String)ibra ); // warning
Math.random();
}
public void intStringConv() {
Object a = 5;
Object b = "string";
int w = Integer.parseInt((String)a);
int x = Integer.parseInt( (String)a); // warning
double y = Double.parseDouble((String)a ); // warning
float z = Float.parseFloat( (String)a ); // warning
String d = ((String)b);
}
public int something( Object o ) { // warning
if ( o == null || !( o instanceof Float ) ) { // warning
return -1;
}
return Integer.valueOf( 22 ).compareTo( (Integer) o ); // warning
}
private void launch(Integer number ) { // warning
String myInt = ( number.toString() + '\0' ); // warning
boolean result = false;
if (number == 123)
result = true;
}
private static String getterName( Exception t) { // warning
if (t instanceof ClassNotFoundException ) { // warning
return ( (ClassNotFoundException) t ).getMessage(); // warning
}
else {
return "?";
}
}
private Object exam;
public String testing() {
return ( this.exam != null ) // warning
? ( ( Enum )this.exam ).name() // warning
: null;
}
Object stringReturnValue( Object result ) { // warning
if ( result instanceof String ) { // warning
result = ( (String) result ).length(); // warning
}
return result;
}
private void except() {
java.util.ArrayList<Integer> arrlist = new java.util.ArrayList<Integer>( 5 ); // warning
arrlist.add( 20); // warning
arrlist.add(15 ); // warning
arrlist.add( 30 ); // warning
arrlist.add(45);
try {
( arrlist ).remove( 2); // warning
} catch ( IndexOutOfBoundsException x ) { // warning
x.getMessage();
}
org.junit.Assert.assertThat( "123", org.hamcrest.CoreMatchers.is( "123" ) ); // warning
org.junit.Assert.assertThat( "Help! Integers don't work", // warning
0, org.hamcrest.CoreMatchers.is( 1 ) ); // warning
}
private void tryWithResources() throws Exception {
try (AutoCloseable a = null) {} // ok
try (AutoCloseable a = null; AutoCloseable b = null) {} // ok
try (AutoCloseable a = null; AutoCloseable b = null; ) {} // ok
try (AutoCloseable a = null; AutoCloseable b = null; ) {} // ok
try (AutoCloseable a = null ) {} // warning
try (AutoCloseable a = null; AutoCloseable b = null ) {} // warning
}
}