View Javadoc
1   /*
2   EmptyLineSeparator
3   allowNoEmptyLineBetweenFields = (default)false
4   allowMultipleEmptyLines = (default)true
5   allowMultipleEmptyLinesInsideClassMembers = (default)true
6   tokens = (default)PACKAGE_DEF, IMPORT, STATIC_IMPORT, CLASS_DEF, INTERFACE_DEF, ENUM_DEF, \
7            STATIC_INIT, INSTANCE_INIT, METHOD_DEF, CTOR_DEF, VARIABLE_DEF, RECORD_DEF, \
8            COMPACT_CTOR_DEF
9   
10  
11  */
12  package com.puppycrawl.tools.checkstyle.checks.whitespace.emptylineseparator; // violation ''package' should be separated from previous line.'
13  
14  
15  
16  // warn
17  
18  
19  
20  import java.lang.Object; // ok
21  
22  import java.lang.Class; // ok
23  
24  
25  // ok
26  import java.lang.Integer;
27  
28  // ok
29  import java.lang.Long;
30  
31  
32  /*
33   * javadoc
34   */
35  import java.lang.Float;
36  
37  /*
38   * javadoc
39   */
40  import java.lang.Double;
41  
42  
43  /**
44   * javadoc
45   */
46  import java.lang.Character;
47  
48  /**
49   * javadoc
50   */
51  import java.lang.String;
52  
53  /*
54   * javadoc
55   */
56  /* javadoc */
57  import java.lang.Object;
58  
59  
60  // ok
61  // .
62  import java.lang.Boolean;
63  // ok
64  import java.lang.Byte;
65  
66  // ok
67  /* javadoc */
68  import java.lang.Short;
69  
70  
71  /* ok javadoc */
72  // .
73  import java.lang.Number;
74  
75  
76  import java.lang.Runnable;
77  import java.lang.Thread;
78  
79  // ok
80  
81  
82  // ok
83  import java.lang.StringBuilder;
84  
85  
86  /*
87   * javadoc
88   */
89  import static java.lang.Math.abs;
90  
91  public class InputEmptyLineSeparatorWithComments2 {
92  
93  
94      public int testViolationWithoutComment = 1;
95  
96      public int testNoViolationWithoutComment = 2; // ok
97  
98  
99      // Should have violation
100     public int testViolationWithSingleLineComment = 3;
101 
102     // Should not have violations
103     public int testNoViolationWithSingleLineComment = 4;
104 
105 
106     /*
107      * Should have
108      * something
109      */
110     public int testViolationWithMultilineComment = 5;
111 
112     /*
113      * Should not have
114      * something
115      */
116     public int testNoViolationWithMultilineComment = 6;
117 
118 
119     /**
120      * Should have
121      * something
122      */
123     public int testViolationWithJavadoc = 7;
124 
125     /**
126      * Should not have
127      * something
128      */
129     public int testNoViolationWithJavadoc = 8;
130 
131 
132     public void testViolationWithoutComment() {
133     } // ok
134 
135     public void testNoViolationWithoutComment() {
136     } // ok
137 
138 
139     // Should be ok
140     public void testViolationWithSingleLineComment() {
141     }
142 
143     // Should not have
144     // something
145     public void testNoViolationWithSingleLineComment() {
146     }
147 
148 
149     /*
150      * Should have
151      * something
152      */
153     public void testViolationWithMultilineComment() {
154     }
155 
156     /*
157      * Should not have
158      * something
159      */
160     public void testNoViolationWithMultilineComment() {
161     }
162 
163 
164     /**
165      * Should have
166      * something
167      */
168     public void testViolationWithJavadoc() {
169     }
170 
171     /**
172      * Should not have
173      * something
174      */
175     public void testNoViolationWithJavadoc() {
176     }
177 
178     public static class Class1 { } // ok
179 
180 
181     public static class Class2 { } // ok
182 
183     // ok
184     public static class Class3 { }
185 
186 
187     // ok
188     public static class Class4 { }
189 
190 
191     // ok
192     public
193     // ok
194     static class Class5 { }
195 
196 
197     // ok
198     public
199     /* javadoc  */
200     static class Class6 { }
201 
202     /*
203      * Should not have
204      * something
205      */
206     public static class Class7 { }
207 
208 
209     /*
210      * Should have
211      * something
212      */
213     public static class Class8 { }
214 
215     /**
216      * Should not have
217      * something
218      */
219     public static class Class9 { }
220 
221 
222     /**
223      * Should have
224      * something
225      */
226     public static class Class10 {
227         {
228             // ok
229         }
230     }
231 
232     // ok
233     public interface Interface1 { }
234 
235 
236     // ok
237     public interface Interface2 { }
238     // ok
239     public // violation ''INTERFACE_DEF' should be separated from previous line.'
240     // .
241     interface Interface3 { }
242 
243 
244     /* something */
245     /* . */
246     /* . */
247     /* . */
248     interface Interface4 { }
249 
250     // ok
251 
252     // ok
253     // .
254     // .
255     // .
256     interface Interface5 { }
257 
258 
259     // ok
260     public enum Enum1 {
261         E1, E2
262     }
263 
264     // ok
265     public enum Enum2 { }
266 
267 
268     // ok
269     // ok
270 
271     // ok
272     public enum Enum3 { }
273     // ok
274 
275     public enum Enum4 { }
276     // ok
277 
278     public enum Enum5 { }
279 
280 
281     // ok
282 
283     public
284 
285 
286     // ok
287     static
288 
289     enum Enum6 { }
290 
291 
292     // ok
293     static {
294         abs(2);
295     }
296 
297     // ok
298 
299 
300     // ok
301     {
302        abs(1);
303     }
304 
305     /* something */
306     { }
307 
308 
309     // ok
310     {
311         int i = 1;
312     }
313 
314 
315     // ok
316     // .
317     /* . */ public InputEmptyLineSeparatorWithComments2() {
318         testNoViolationWithJavadoc = 1;
319     }
320 
321     // ok
322     /* . */ public InputEmptyLineSeparatorWithComments2(int i) {
323         testNoViolationWithJavadoc = 1;
324     }
325 
326     // ok
327     // ok
328 
329     // ok
330     public InputEmptyLineSeparatorWithComments2(int i, int j) {
331         testNoViolationWithJavadoc = 1;
332     }
333 
334 
335     // ok
336     // ok
337 
338     // ok
339 
340 
341 
342 
343     // ok
344     public InputEmptyLineSeparatorWithComments2(int i, int j, int k) {
345         testNoViolationWithJavadoc = 1;
346     }
347 
348 }