1   ////////////////////////////////////////////////////////////////////////////////
2   // Test case file for checkstyle.
3   // Created: 2003
4   ////////////////////////////////////////////////////////////////////////////////
5   
6   package com.puppycrawl.tools.checkstyle.checks.javadoc.javadocstyle;
7   
8   /**
9    * Test input for the JavadocStyleCheck.  This check is used to perform 
10   * some additional Javadoc validations.  
11   * 
12   * @author Chris Stillwell
13   * @version 1.0
14   */
15  public class InputJavadocStyle
16  {
17     // This is OK. We don't flag missing javadoc.  That's left for other checks.
18     private String first;
19     
20     /** This Javadoc is missing an ending period */
21     private String second;
22     
23     /**
24      * We don't want {@link com.puppycrawl.tools.checkstyle.checks.JavadocStyleCheck} 
25      * tags to stop the scan for the end of sentence. 
26      * @see Something
27      */
28     public InputJavadocStyle()
29     {
30     }
31     
32     /**
33      * This is ok!
34      */
35     private void method1()
36     {
37     }
38     
39     /**
40      * This is ok?
41      */
42     private void method2()
43     {
44     }
45     
46     /**
47      * And This is ok.<br>
48      */
49     private void method3()
50     {
51     }
52     
53     /**
54      * This should fail even.though.there are embedded periods
55      */
56     private void method4()
57     {
58     }
59     
60     /**
61      * Test HTML in Javadoc comment
62      * <dl>
63      * <dt><b>This guy is missing end of bold tag
64      * <dd>The dt and dd don't require end tags.
65      * </dl>
66      * </td>Extra tag shouldn't be here
67      * 
68      * @param arg1 <code>dummy.
69      */
70     private void method5(int arg1)
71     {
72     }
73     
74     /**
75      * Protected check <b>should fail
76      */
77     protected void method6()
78     {
79     }
80     
81     /**
82      * Package protected check <b>should fail
83      */
84     void method7()
85     {
86     }
87     
88     /**
89      * Public check should fail</code>
90      * should fail <
91      */
92     public void method8()
93     {
94     }
95     
96     /** {@inheritDoc} **/
97     public void method9()
98     {
99     }
100 
101     
102     // Testcases to exercise the Tag parser (bug 843887)
103 
104     /**
105      * Real men don't use XHTML.
106      * <br />
107      * <hr/>
108      * < br/>
109      * <img src="schattenparker.jpg"/></img>
110      */
111     private void method10()
112     { // </img> should be the only error
113     }
114 
115     /**
116      * Tag content can be really mean.
117      * <p>
118      * Sometimes a p tag is closed.
119      * </p>
120      * <p>
121      * Sometimes it's not.
122      * 
123      * <span style="font-family:'Times New Roman',Times,serif;font-size:200%">
124      * Attributes can contain spaces and nested quotes.
125      * </span>
126      * <img src="slashesCanOccurWithin/attributes.jpg"/>
127      * <img src="slashesCanOccurWithin/attributes.jpg">
128      * <!-- comments <div> should not be checked. -->
129      */
130     private void method11()
131     { // JavadocStyle should not report any error for this method
132     }
133 
134     /**
135      * Tags for two lines.
136      * <a href="some_link"
137      * >Link Text</a>
138      */
139     private void method12()
140     {// JavadocStyle should not report any error for this method
141     }
142 
143     /**
144      * First sentence.
145      * <pre>
146      * +--LITERAL_DO (do)
147      *     |
148      *     +--SLIST ({)
149      *         |
150      *         +--EXPR
151      *             |
152      *             +--ASSIGN (=)
153      *                 |
154      *                 +--IDENT (x)
155      *                 +--METHOD_CALL (()
156      *                     |
157      *                     +--DOT (.)
158      *                         |
159      *                         +--IDENT (rand)
160      *                         +--IDENT (nextInt)
161      *                     +--ELIST
162      *                         |
163      *                         +--EXPR
164      *                             |
165      *                             +--NUM_INT (10)
166      *                     +--RPAREN ())
167      *         +--SEMI (;)
168      *         +--RCURLY (})
169      *     +--LPAREN (()
170      *     +--EXPR
171      *         |
172      *         +--LT (<)
173      *             |
174      *             +--IDENT (x)
175      *             +--NUM_INT (5)
176      *     +--RPAREN ())
177      *     +--SEMI (;)
178      * </pre>
179      */
180     private void method13()
181     {// JavadocStyle should not report any error for this method
182     }
183 
184     /**
185      * Some problematic javadoc. Sample usage:
186      * <blockquote>
187      */
188 
189     private void method14()
190     { // empty line between javadoc and method is critical (bug 841942)
191     }
192 
193     /**
194      * Empty line between javadoc and method declaration cause wrong
195      * line number for reporting error (bug 841942)
196      */
197 
198     private void method15()
199     { // should report unended first sentence (check line number of the error)
200     }
201 
202     /** Description of field: {@value}. */
203     public static final int dummy = 4911;
204 
205     /**
206      */
207     public void method16()
208     { // should report empty javadoc
209     }
210 
211     /**
212      * @param a A parameter
213      */
214     protected void method17(String a)
215     { // should report empty javadoc (no text before parameter)
216     }
217 
218     /**
219      * @exception RuntimeException should be thrown
220      */
221     void method18(String a)
222     { // should report empty javadoc (no text before exception)
223     }
224 
225     /** 
226      */
227     private static int ASDF = 0;
228     // should report empty javadoc
229 
230     /** @see java.lang.Object */
231     public void method19()
232     {  // should report empty javadoc (no text before see tag)
233     }
234 
235     public enum Test
236         //Should complain about no javadoc
237     {
238         /**
239          * Value 1 without a period
240          */
241         value1,
242 
243         /**
244          * Value 2 with a period.
245          */
246         value2,
247     }
248 
249     /**
250     * A test class.
251     * @param <T1> this is NOT an unclosed T1 tag
252     * @param <KEY_T> for bug 1649020.
253     * @author <a href="mailto:foo@nomail.com">Foo Bar</a>
254     */
255     public class TestClass<T1, KEY_T>
256     {
257         /**
258         * Retrieves X.
259         * @return a value
260         */
261         public T1 getX()
262         {
263             return null;
264         }
265 
266         /**
267         * Retrieves Y.
268         * @param <V> this is not an unclosed V tag
269         * @return a value
270         */
271         public <V> V getY()
272         {
273             return null;
274         }
275         
276         /**
277          * Retrieves Z.
278          * 
279          * @param <KEY_T1> this is not an unclosed KEY_T tag
280          * @return a value
281          */
282         public <KEY_T1> KEY_T getZ_1649020_1()
283         {
284             return null;
285         }
286         
287         /**
288          * Retrieves something.
289          * 
290          * @param <KEY_T_$_1_t> strange type
291          * @return a value
292          */
293         public <KEY_T_$_1_t> KEY_T_$_1_t getEh_1649020_2() {
294             return null;
295         }
296         
297         /**
298          * Retrieves more something.
299          * 
300          * @param <$_12_xY_z> strange type
301          * @return a value
302          */
303         public <$_12_xY_z> $_12_xY_z getUmmm_1649020_3() {
304             return null;
305         }
306     }
307 
308     /**
309      * Checks if the specified IClass needs to be
310      * annotated with the @Type annotation.
311      */
312     public void foo_1291847_1() {
313     }
314 
315     /**
316      * Returns the string containing the properties of
317      * <code>@Type</code> annotation.
318      */
319     public void foo_1291847_2() {
320     }
321 
322 		/**
323 		 * Checks generics javadoc.
324 		 * 
325 		 * @param strings this is a List<String>
326 		 * @param test Map<String, List<String>> a map indexed on String of Lists of Strings.
327 		 */
328 		public void method20() {
329 		}
330 
331 		/**
332 		 * Checks HTML tags in javadoc.
333 		 * 
334 		 * HTML no good tag
335 		 * <string>Tests</string>
336 		 *
337 		 */
338 		public void method21() {
339 		}
340 
341         /**
342          * First sentence.
343          * <
344          * /a>
345          */
346         void tagClosedInNextLine() {
347             
348         } 
349 
350         /**
351          * Link to some page in two lines.
352          * <a
353          * href="someLink"/>
354          */
355         void tagInTwoLines() {
356             
357         }
358 
359         /**
360          * This Javadoc contains unclosed tag.
361          * <code>unclosed 'code' tag<code>
362          */
363         private void unclosedTag() {}
364 
365         void javadocLikeCommentInMethod() {
366             /**
367              * It pretends to be Javadoc without dot, but it's just comment in method
368              */
369             final int i = 0;
370         }
371 
372         /**
373          * {@inheritDoc}
374          */
375         private void inheritDoc() {}
376 
377         /**
378          * <p><b>Note:<b> it's unterminated tag.</p>
379          */
380         private void unterminatedTag() {}
381 
382         /**
383          * Javadoc without dot
384          */
385         public interface TestInterface {
386             /**
387              * Javadoc without dot
388              */
389             void method();
390         }
391 
392         static class TestStaticClass {
393             /**
394              * Javadoc without dot
395              */
396             public int field;
397         }
398 
399         /**
400          * .
401          * @throws Exception if an error occurs
402          */
403         void foo() throws Exception {}
404         
405         /**
406          * text /
407          * @throws Exception if an error occurs
408          */
409         void bar() throws Exception {}
410 
411         /**
412          * {@inheritDoc}
413          * <p>
414          * @throws IllegalArgumentException with errMsg as its message
415          */
416         void inheritDocWithThrows() {}
417         
418         /**
419          * /
420          *
421          **
422          * @param s
423          * @return Return
424          */
425         public int test(String s) { return 0; }
426 
427     /** Set of all class field names.*/
428     public String field;
429 
430     /**
431      * <p>Test.</p>
432      * <pre class="body">
433          for (
434           ; i &lt; j; i++, j--) {}
435        </pre>
436      */
437     public void test2() {}
438 
439     /**
440      * <p>Test.</p>
441      * <pre><code>&#064;ExtendWith(SpotBugsExtension.class)
442 public class SampleTest {
443 }</code></pre>
444      */
445     public void test3() {}
446 }