View Javadoc
1   package de.japrost.qa.checkstyle.blocks;
2   
3   /**
4    * Test the EmtpyBlock checkstyle rules.
5    */
6   public class EmptyBlock {
7   	private boolean bool = true;
8   
9   	/**
10  	 * STATIC_INIT empty
11  	 */
12  	static {
13  	}
14  
15  	/**
16  	 * STATIC_INIT with text
17  	 */
18  	static {
19  		//
20  	}
21  
22  	/**
23  	 * STATIC_INIT with stmt
24  	 */
25  	static {
26  		;
27  	}
28  
29  	/**
30  	 * INSTANCE_INIT empty
31  	 */
32  	{
33  	}
34  
35  	/**
36  	 * INSTANCE_INIT with text
37  	 */
38  	{
39  		//
40  	}
41  
42  	/**
43  	 * INSTANCE_INIT with stmt
44  	 */
45  
46  	{
47  		;
48  	}
49  
50  	public void blocksEmpty() {
51  		// LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY
52  		try {
53  		} catch (Exception e) {
54  		} finally {
55  		}
56  		// LITERAL_WHILE
57  		while (bool) {
58  		}
59  		// LITERAL_DO
60  		do {
61  		} while (bool);
62  		// LITERAL_IF, LITERAL_ELSE
63  		if (bool) {
64  		} else {
65  		}
66  		// LITERAL_FOR
67  		for (int i = 0; i < 1; i++) {
68  		}
69  		// LITERAL_SWITCH
70  		switch (1) {
71  		}
72  		// LITERAL_CASE
73  		switch (1) {
74  		case 1:
75  		}
76  		// LITERAL_DEFAULT
77  		switch (1) {
78  		default:
79  		}
80  		// LITERAL_SYNCHRONIZED
81  		synchronized (this) {
82  		}
83  		// ARRAY_INIT
84  		@SuppressWarnings("unused")
85  		int[] arrayInit = {};
86  	}
87  
88  	public void blocksWithText() {
89  		// LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY
90  		try {
91  			//
92  		} catch (Exception e) {
93  			//
94  		} finally {
95  			//
96  		}
97  		// LITERAL_WHILE
98  		while (bool) {
99  			//
100 		}
101 		// LITERAL_DO
102 		do {
103 			//
104 		} while (bool);
105 		// LITERAL_IF, LITERAL_ELSE
106 		if (bool) {
107 			//
108 		} else {
109 			//
110 		}
111 		// LITERAL_FOR
112 		for (int i = 0; i < 1; i++) {
113 			//
114 		}
115 		// LITERAL_SWITCH
116 		switch (1) {
117 		//
118 		}
119 		// LITERAL_CASE
120 		switch (1) {
121 		case 1:
122 			//
123 		}
124 		// LITERAL_DEFAULT
125 		switch (1) {
126 		default:
127 			//
128 		}
129 		// LITERAL_SYNCHRONIZED
130 		synchronized (this) {
131 			//
132 		}
133 		// ARRAY_INIT
134 		@SuppressWarnings("unused")
135 		int[] arrayInit = { //
136 		};
137 	}
138 
139 	public void blocksWithStmt() {
140 		// LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY
141 		try {
142 			;
143 		} catch (Exception e) {
144 			;
145 		} finally {
146 			;
147 		}
148 		// LITERAL_WHILE
149 		while (bool) {
150 			;
151 		}
152 		// LITERAL_DO
153 		do {
154 			;
155 		} while (bool);
156 		// LITERAL_IF, LITERAL_ELSE
157 		if (bool) {
158 			;
159 		} else {
160 			;
161 		}
162 		// LITERAL_FOR
163 		for (int i = 0; i < 1; i++) {
164 			;
165 		}
166 		// LITERAL_SWITCH
167 		// switch (1) {
168 		// ;
169 		// }
170 		// LITERAL_CASE
171 		switch (1) {
172 		case 1:
173 			;
174 		}
175 		// LITERAL_DEFAULT
176 		switch (1) {
177 		default:
178 			;
179 		}
180 		// LITERAL_SYNCHRONIZED
181 		synchronized (this) {
182 			;
183 		}
184 		// ARRAY_INIT
185 		@SuppressWarnings("unused")
186 		int[] arrayInit = { 1 };
187 	}
188 
189 }