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
|
package com.puppycrawl.tools.checkstyle;
public class InputRightCurlyAloneOrSingleline {
public boolean equals(Object other) { boolean flag = true; return flag; }
public int hashCode()
{
int a = 10;
return 1;
}
private void foo()
{ int var1 = 5; var2 = 6; }
private void foo1() { return; }
private String foo2() { return toString();
}
private void foo3() { ; return; }
private int var1;
private int var2;
public InputRightCurlyAloneOrSingleline() { this.var1 = 1; }
public InputRightCurlyAloneOrSingleline(int var1, int var2) { this.var1 = var1; this.var2 = var2; }
private void foo4() { ;; }
private void foo5() { ; }
private void foo6() { }
private void foo12() {
try { int i = 5; int b = 10; }
catch (Exception e) { }
}
private void foo13() {
for (int i = 0; i < 10; i++) { int a = 5; int b = 6; }
do
{
var1 = 2;
}
while (var2 == 2);
}
static { int a; int b; }
{ int c; int d;}
private void foo14() {
if (var1 > 0) {
return;
}
}
private void foo15() {
class A { int a; } var1++; //violation
class B { }
if(true) {
}
else;
}
private void foo16() {
if (true) { return; } else { } //violation
if (false) {
}
}
private void foo17() { int var1 = 5; var2 = 6; } private void foo18() {int var1 = 5; var2 = 6; } //violation
private void foo19() {int var1 = 5;
var2 = 6;} //violation
private String foo20() {
do { var2 ++; }
while (var2 < 15);
while (var1 < 10) { var1++; }
do { var2++; var1++; } while (var2 < 15); return ""+0xCAFEBABE; //violation
}
private void foo21() {
new Object() { @Override protected void finalize() { "".toString(); }};
}
void foo22() {
long startTime = System.nanoTime();
try {
int a = 5;
toString();
} catch (Exception e) { //violation
throw new RuntimeException(e);
} finally { toString(); } //violation
}
void doDoubleBraceInitialization() {
java.util.Map<String, String> map = new java.util.LinkedHashMap<String, String>() {{
put("Hello", "World");
put("first", "second");
put("polygene", "lubricants");
put("alpha", "betical");
}}; // it's ok
Thread t = new Thread() {@Override public void run() {super.run();}};
new Object() { @Override protected void finalize() { "".toString(); } { int a = 5; }};
new Object() { @Override protected void finalize() { "".toString(); } int b = 10; };
new Object() { @Override protected void finalize() { "".toString(); } { int c = 5; } int d = 8; };
java.util.Map<String, String> map2 = new java.util.LinkedHashMap<String, String>() {{
put("Hello", "World");
put("first", "second");
put("polygene", "lubricants");
put("alpha", "betical");} //violation
};
java.util.Map<String, String> map3 = new java.util.LinkedHashMap<String, String>() {{
put("Hello", "World");
put("first", "second");
put("polygene", "lubricants");
put("alpha", "betical");}}; //violation
java.util.Map<String, String> map4 = new java.util.LinkedHashMap<String, String>() {{
put("Hello", "World");
put("first", "second");
put("polygene", "lubricants");
put("alpha", "betical");
}
};
foo23(new java.util.HashSet<String>() {{
add("XZ13s");
add("AB21/X");
add("YYLEX");
add("AR5E");
}}); //it's ok, can't be formatted better
foo23(new java.util.HashSet<String>() {{
add("XZ13s");
add("AB21/X");
add("YYLEX");
add("AR5E");
}});} //violation
void foo23(java.util.HashSet<String> set) {
}
void foo25() {
for (int i = 0; i < 10; i++) {
System.out.println("Hello, world!");
}} //violation
void foo26() {
for (int i = 0; i < 10; i++) {
System.out.println("Hello, world!");}} //violation
void foo27() {
for (int i = 0; i < 10; i++) {for (int j = 0; j < 15; j++) {int a;}}} //violation
private java.util.ArrayList<Integer> foo28(int delta) {
return new java.util.ArrayList<Integer>() {
@Override public int size() { return Math.max(0, super.size() + 1);};
};
}
private void foo29() {
boolean flag = true;
if (flag) {
System.out.println("heh");
flag = !flag; } System.err. //violation
println("Xe-xe");
}
}
|