View Javadoc
1   package // violation 'package statement should not be line-wrapped.'
2       // violation below 'Javadoc comment is placed in the wrong location.'
3       /** invalid javadoc. */
4       com.google.checkstyle.test.chapter7javadoc.rule711generalform;
5   
6   // violation below 'Javadoc comment is placed in the wrong location.'
7   /** invalid javadoc. */
8   import javax.swing.JFrame;
9   
10  /** some javadoc. */
11  public class InputSingleLineJavadocAndInvalidJavadocPosition {
12  
13    /** As of JDK 1.1, replaced by {@link #setBounds(int,int,int,int)}. */
14    void foo1() {}
15  
16    /** As of JDK 1.1, replaced by {@link #setBounds(int,int,int,int)}. */
17    void foo2() {}
18  
19    /** @throws CheckstyleException if a problem occurs */
20    // 3 violations above:
21    //  'Javadoc tag '@throws' should be preceded with an empty line.'
22    //  'Single-line Javadoc comment should be multi-line.'
23    //  'Summary javadoc is missing.'
24    void foo3() {}
25  
26    /**
27     * summary.
28     *
29     * @throws CheckstyleException if a problem occurs
30     */
31    void foo4() {}
32  
33    /** An especially short bit of Javadoc. */
34    void foo5() {}
35  
36    /** An especially short bit of Javadoc. */
37    void foo6() {}
38  
39    // 3 violations 4 lines below:
40    //  'Javadoc tag '@inheritDoc' should be preceded with an empty line.'
41    //  'Single-line Javadoc comment should be multi-line.'
42    //  'Summary javadoc is missing.'
43    /** @inheritDoc */
44    void foo7() {}
45  
46    /** {@inheritDoc} */
47    void foo8() {}
48  
49    // 3 violations 4 lines below:
50    //  'Javadoc tag '@customTag' should be preceded with an empty line.'
51    //  'Single-line Javadoc comment should be multi-line.'
52    //  'Summary javadoc is missing.'
53    /** @customTag */
54    void bar() {}
55  
56    /**
57     * summary.
58     *
59     * <h1>Some header </h1>
60     *
61     * {@inheritDoc} {@code bar1} text
62     */
63    void bar2() {}
64  
65    // 3 violations 4 lines below:
66    //  'Javadoc tag '@customTag' should be preceded with an empty line.'
67    //  'Single-line Javadoc comment should be multi-line.'
68    //  'Summary javadoc is missing.'
69    /** @customTag <a> href="https://github.com/checkstyle/checkstyle/"</a>text */
70    void bar3() {}
71  
72    /** Single line Javadoc that references {@link String}. */
73    void bar4() {}
74  
75    // 3 violations 4 lines below:
76    //  'Javadoc tag '@return' should be preceded with an empty line.'
77    //  'Single-line Javadoc comment should be multi-line.'
78    //  'Summary javadoc is missing.'
79    /** @return in single line javadoc */
80    int bar5() {
81      return 0;
82    }
83  
84    /**
85     * summary.
86     *
87     * @return in multi line javadoc
88     */
89    int bar6() {
90      return 0;
91    }
92  }
93  
94  // violation below 'Javadoc comment is placed in the wrong location.'
95  /** invalid javadoc. */
96  /** valid javadoc. */
97  class InputInvalidJavadocPosition {
98    // violation above '.* InputInvalidJavadocPosition has to reside in its own source file.'
99    // violation below 'Javadoc comment is placed in the wrong location.'
100   /** invalid javadoc. */
101 }
102 
103 /** valid javadoc. */
104 /* ignore */
105 class InputInvalidJavadocPosition2 {
106   // violation above '.* InputInvalidJavadocPosition2 has to reside in its own source file.'
107   // violation below 'Javadoc comment is placed in the wrong location.'
108   /** invalid javadoc. */
109   static {
110     /* ignore */
111   }
112 
113   // violation below 'Javadoc comment is placed in the wrong location.'
114   /** invalid javadoc. */
115   /** valid javadoc. */
116   int field1;
117 
118   /** valid javadoc. */
119   int[] field2;
120 
121   /** valid javadoc. */
122   public int[] field3;
123 
124   /** valid javadoc. */
125   @Deprecated int field4;
126 
127   // violation 2 lines below 'Javadoc comment is placed in the wrong location.'
128   int
129       /** invalid javadoc. */
130       field20;
131 
132   // violation 2 lines below 'Javadoc comment is placed in the wrong location.'
133   int field21
134       /** invalid javadoc. */
135       ;
136 
137   // violation 2 lines below 'Javadoc comment is placed in the wrong location.'
138   @Deprecated
139   /** invalid javadoc. */
140   JFrame frame = new JFrame();
141 
142   void method1() {}
143 
144   /** valid javadoc. */
145   void method2() {}
146 
147   /** valid javadoc. */
148   <T> T method3() {
149     return null;
150   }
151 
152   /** valid javadoc. */
153   String[] method4() {
154     return null;
155   }
156 
157   // violation 2 lines below 'Javadoc comment is placed in the wrong location.'
158   void
159       /** invalid javadoc. */
160       method20() {}
161 
162   // violation 2 lines below 'Javadoc comment is placed in the wrong location.'
163   void method21
164   /** invalid javadoc. */
165   () {} // violation ''(' should be on the previous line.'
166 
167   // violation 2 lines below 'Javadoc comment is placed in the wrong location.'
168   void method22(
169   /** invalid javadoc. */
170   ) {}
171 
172   // violation 2 lines below 'Javadoc comment is placed in the wrong location.'
173   void method23()
174     /** invalid javadoc. */
175     {}
176 
177   // violation 2 lines below 'Javadoc comment is placed in the wrong location.'
178   void method24() {
179     /** invalid javadoc. */
180   }
181 
182   // violation 2 lines below 'Javadoc comment is placed in the wrong location.'
183   void method25() {
184     /** invalid javadoc. */
185     int variable;
186   }
187 }
188 
189 // violation 2 lines below '.* InputInvalidJavadocPosition3 has to reside in its own source file.'
190 // violation 2 lines below 'Javadoc comment is placed in the wrong location.'
191 @Deprecated
192 /** invalid javadoc. */
193 class InputInvalidJavadocPosition3 {}
194 
195 // violation 2 lines below '.* InputInvalidJavadocPosition4 has to reside in its own source file.'
196 /** valid javadoc. */
197 @Deprecated
198 class InputInvalidJavadocPosition4 {}
199 
200 // violation 2 lines below '.* InputInvalidJavadocPosition5 has to reside in its own source file.'
201 // violation 2 lines below 'Javadoc comment is placed in the wrong location.'
202 class
203 /** invalid javadoc. */
204 InputInvalidJavadocPosition5 {}
205 // violation above ''InputInvalidJavadocPosition5' has incorrect indentation .* 0, expected .* 4.'
206 
207 // violation 2 lines below '.* InputInvalidJavadocPosition6 has to reside in its own source file.'
208 // violation 2 lines below 'Javadoc comment is placed in the wrong location.'
209 class InputInvalidJavadocPosition6
210   /** invalid javadoc. */
211   {}
212 /** invalid javadoc. */
213 // violation 2 lines above''}' at column 4 should be alone on a line.'
214 // violation 2 lines above 'Javadoc comment is placed in the wrong location.'