-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
config_javadoc.xml
4103 lines (3852 loc) · 148 KB
/
config_javadoc.xml
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="UTF-8"?>
<document xmlns="http://maven.apache.org/XDOC/2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd">
<head>
<title>Javadoc Comments</title>
</head>
<body>
<section name="Content">
<macro name="toc">
<param name="fromDepth" value="1"/>
<param name="toDepth" value="1"/>
</macro>
</section>
<section name="AtclauseOrder">
<p>Since Checkstyle 6.0</p>
<subsection name="Description" id="AtclauseOrder_Description">
<p>
Checks the order of
<a href="https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html#CHDBEFIF">
javadoc block-tags or javadoc tags</a>.
</p>
<p>
Note: Google used the term "at-clauses" for block tags in their guide till 2017-02-28.
</p>
</subsection>
<subsection name="Properties" id="AtclauseOrder_Properties">
<div class="wrapper">
<table>
<tr>
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
<th>since</th>
</tr>
<tr>
<td>violateExecutionOnNonTightHtml</td>
<td>
Control when to print violations if the Javadoc being examined by this check
violates the tight html rules defined at
<a href="writingjavadocchecks.html#Tight-HTML_rules">Tight-HTML Rules</a>.
</td>
<td><a href="property_types.html#boolean">boolean</a>
</td>
<td><code>false</code></td>
<td>8.3</td>
</tr>
<tr>
<td>target</td>
<td>Specify block tags targeted.</td>
<td>subset of tokens
<a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html">TokenTypes</a>
</td>
<td>
<a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CLASS_DEF">
CLASS_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#COMPACT_CTOR_DEF">
COMPACT_CTOR_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">
CTOR_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ENUM_DEF">
ENUM_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INTERFACE_DEF">
INTERFACE_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">
METHOD_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#RECORD_DEF">
RECORD_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#VARIABLE_DEF">
VARIABLE_DEF</a>
</td>
<td>6.0</td>
</tr>
<tr>
<td>tagOrder</td>
<td>Specify the order by tags.</td>
<td><a href="property_types.html#String.5B.5D">String[]</a></td>
<td><code>@author, @deprecated, @exception, @param,
@return, @see, @serial, @serialData, @serialField,
@since, @throws, @version</code></td>
<td>6.0</td>
</tr>
</table>
</div>
</subsection>
<subsection name="Examples" id="AtclauseOrder_Examples">
<p>
To configure the default check:
</p>
<source>
<module name="AtclauseOrder"/>
</source>
<p>
Example:
</p>
<source>
/**
* Some javadoc. // OK
*
* @author Some javadoc. // OK
* @version Some javadoc. // OK
* @param Some javadoc. // OK
* @return Some javadoc. // OK
* @throws Some javadoc. // OK
* @exception Some javadoc. // OK
* @see Some javadoc. // OK
* @since Some javadoc. // OK
* @serial Some javadoc. // OK
* @serialField // OK
* @serialData // OK
* @deprecated Some javadoc. // OK
*/
class Valid implements Serializable
{
}
/**
* Some javadoc.
*
* @since Some javadoc. // OK
* @version Some javadoc. // Violation - wrong order
* @deprecated
* @see Some javadoc. // Violation - wrong order
* @author Some javadoc. // Violation - wrong order
*/
class Invalid implements Serializable
{
}
</source>
</subsection>
<subsection name="Example of Usage" id="AtclauseOrder_Example_of_Usage">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Agoogle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+AtclauseOrder">
Google Style</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+AtclauseOrder">
Checkstyle Style</a>
</li>
</ul>
</subsection>
<subsection name="Violation Messages" id="AtclauseOrder_Violation_Messages">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fjavadoc+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22at.clause.order%22">
at.clause.order</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fjavadoc+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22javadoc.missed.html.close%22">
javadoc.missed.html.close</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fjavadoc+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22javadoc.parse.rule.error%22">
javadoc.parse.rule.error</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fjavadoc+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22javadoc.wrong.singleton.html.tag%22">
javadoc.wrong.singleton.html.tag</a>
</li>
</ul>
<p>
All messages can be customized if the default message doesn't suit you.
Please <a href="config.html#Custom_messages">see the documentation</a> to learn how to.
</p>
</subsection>
<subsection name="Package" id="AtclauseOrder_Package">
<p>
com.puppycrawl.tools.checkstyle.checks.javadoc
</p>
</subsection>
<subsection name="Parent Module" id="AtclauseOrder_Parent_Module">
<p>
<a href="config.html#TreeWalker">TreeWalker</a>
</p>
</subsection>
</section>
<section name="InvalidJavadocPosition">
<p>Since Checkstyle 8.23</p>
<subsection name="Description" id="InvalidJavadocPosition_Description">
<p>
Checks that Javadocs are located at the correct position.
As specified at <a href="https://docs.oracle.com/en/java/javase/11/docs/specs/doc-comment-spec.html">
Documentation Comment Specification for the Standard Doclet</a>,
Javadocs are recognized only when placed immediately before module, package, class,
interface, constructor, method, or field declarations. Any other position, like
in the body of a method, will be ignored by the javadoc tool and is considered
invalid by this check.
</p>
</subsection>
<subsection name="Examples" id="InvalidJavadocPosition_Examples">
<p>
To configure the check:
</p>
<source>
<module name="InvalidJavadocPosition"/>
</source>
<p>
The following code produces a violation because Javadocs should be before all
annotations of the Javadoc's target:
</p>
<source>
@SuppressWarnings("serial")
/**
* This comment looks like javadoc but it at an invalid location.
* Therefore, the text will not get into TestClass.html and the check will produce a violation.
*/
public class TestClass {
}
</source>
</subsection>
<subsection name="Example of Usage" id="InvalidJavadocPosition_Example_of_Usage">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Agoogle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+InvalidJavadocPosition">
Google Style</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Asun_checks.xml+repo%3Acheckstyle%2Fcheckstyle+InvalidJavadocPosition">
Sun Style</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+InvalidJavadocPosition">
Checkstyle Style</a>
</li>
</ul>
</subsection>
<subsection name="Violation Messages" id="InvalidJavadocPosition_Violation_Messages">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fjavadoc+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22invalid.position%22">
invalid.position</a>
</li>
</ul>
<p>
All messages can be customized if the default message doesn't suit you.
Please <a href="config.html#Custom_messages">see the documentation</a> to learn how to.
</p>
</subsection>
<subsection name="Package" id="InvalidJavadocPosition_Package">
<p>
com.puppycrawl.tools.checkstyle.checks.javadoc
</p>
</subsection>
<subsection name="Parent Module" id="InvalidJavadocPosition_Parent_Module">
<p>
<a href="config.html#TreeWalker">TreeWalker</a>
</p>
</subsection>
</section>
<section name="JavadocBlockTagLocation">
<p>Since Checkstyle 8.24</p>
<subsection name="Description" id="JavadocBlockTagLocation_Description">
<p>
Checks that a
<a href="https://docs.oracle.com/en/java/javase/11/docs/specs/doc-comment-spec.html#block-tags">
javadoc block tag</a> appears only at the beginning of a line, ignoring
leading asterisks and white space. A block tag is a token that starts
with <code>@</code> symbol and is preceded by a whitespace. This check
ignores block tags in comments and inside inline tags {@code } and
{@literal }.
</p>
<p>
Rationale: according to
<a href="https://docs.oracle.com/en/java/javase/11/docs/specs/doc-comment-spec.html#block-tags">
the specification</a> all javadoc block tags should be placed at the
beginning of a line. Tags that are not placed at the beginning are treated
as plain text. To recognize intentional tag placement to text area
it is better to escape the <code>@</code> symbol, and all non-escaped
tags should be located at the beginning of the line. See NOTE section
for details on how to escape.
</p>
</subsection>
<subsection name="Notes" id="JavadocBlockTagLocation_Notes">
<p>
To place a tag explicitly as text, escape the <code>@</code> symbol
with HTML entity &#64; or place it inside <code>{@code }</code>,
for example:
</p>
<source>
/**
* &#64;serial literal in {@code @serial} Javadoc tag.
*/
</source>
</subsection>
<subsection name="Properties" id="JavadocBlockTagLocation_Properties">
<div class="wrapper">
<table>
<tr>
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
<th>since</th>
</tr>
<tr>
<td>tags</td>
<td>Specify the javadoc tags to process.</td>
<td><a href="property_types.html#String.5B.5D">String[]</a></td>
<td><code>author, deprecated, exception, hidden, param, provides, return,
see, serial, serialData, serialField, since, throws, uses, version</code></td>
<td>8.24</td>
</tr>
<tr>
<td>violateExecutionOnNonTightHtml</td>
<td>
Control when to print violations if the Javadoc being examined by this check
violates the tight html rules defined at
<a href="writingjavadocchecks.html#Tight-HTML_rules">Tight-HTML Rules</a>.
</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><code>false</code></td>
<td>8.24</td>
</tr>
</table>
</div>
</subsection>
<subsection name="Examples" id="JavadocBlockTagLocation_Examples">
<p>
To configure the default check:
</p>
<source>
<module name="JavadocBlockTagLocation"/>
</source>
<p>Example:</p>
<source>
/**
* Escaped tag &#64;version (OK)
* Plain text with {@code @see} (OK)
* A @custom tag (OK)
* <!-- @see commented out (OK) -->
* email@author (OK)
* (@param in parentheses) (OK)
* '@param in single quotes' (OK)
* @since 1.0 (OK)
* text @return (violation)
* * @param (violation)
+* @serial (violation)
* @see first (OK) @see second (violation)
*/
public int field;
</source>
<p>
To configure the check to verify tags from
<a href="https://openjdk.org/jeps/8068562">JEP 8068562</a> only:
</p>
<source>
<module name="JavadocBlockTagLocation">
<property name="tags" value="apiNote, implSpec, implNote"/>
</module>
</source>
<p>
To configure the check to verify all default tags and some custom tags in addition:
</p>
<source>
<module name="JavadocBlockTagLocation">
<!-- default tags -->
<property name="tags" value="author, deprecated, exception, hidden"/>
<property name="tags" value="param, provides, return, see, serial"/>
<property name="tags" value="serialData, serialField, since, throws"/>
<property name="tags" value="uses, version"/>
<!-- additional tags used in the project -->
<property name="tags" value="noinspection"/>
</module>
</source>
</subsection>
<subsection name="Example of Usage" id="JavadocBlockTagLocation_Example_of_Usage">
<ul>
<li>
<a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+JavadocBlockTagLocation">
Checkstyle Style</a>
</li>
</ul>
</subsection>
<subsection name="Violation Messages" id="JavadocBlockTagLocation_Violation_Messages">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fjavadoc+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22javadoc.blockTagLocation%22">
javadoc.blockTagLocation</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fjavadoc+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22javadoc.missed.html.close%22">
javadoc.missed.html.close</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fjavadoc+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22javadoc.parse.rule.error%22">
javadoc.parse.rule.error</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fjavadoc+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22javadoc.wrong.singleton.html.tag%22">
javadoc.wrong.singleton.html.tag</a>
</li>
</ul>
<p>
All messages can be customized if the default message doesn't suit you.
Please <a href="config.html#Custom_messages">see the documentation</a> to learn how to.
</p>
</subsection>
<subsection name="Package" id="JavadocBlockTagLocation_Package">
<p>
com.puppycrawl.tools.checkstyle.checks.javadoc
</p>
</subsection>
<subsection name="Parent Module" id="JavadocBlockTagLocation_Parent_Module">
<p>
<a href="config.html#TreeWalker">TreeWalker</a>
</p>
</subsection>
</section>
<section name="JavadocContentLocation">
<p>Since Checkstyle 8.27</p>
<subsection name="Description" id="JavadocContentLocation_Description">
<p>
Checks that the Javadoc content begins from the same position
for all Javadoc comments in the project. Any leading asterisks and spaces
are not counted as the beginning of the content and are therefore ignored.
</p>
<p>
It is possible to enforce two different styles:
</p>
<ul>
<li>
{@code first_line} - Javadoc content starts from the first line:
<source>
/** Summary text.
* More details.
*/
public void method();
</source>
</li>
<li>
{@code second_line} - Javadoc content starts from the second line:
<source>
/**
* Summary text.
* More details.
*/
public void method();
</source>
</li>
</ul>
</subsection>
<subsection name="Notes" id="JavadocContentLocation_Notes">
<p>
This check does not validate the Javadoc summary itself nor its presence.
The check will not report any violations for missing or malformed javadoc summary.
To validate the Javadoc summary use <a href="config_javadoc.html#SummaryJavadoc">
SummaryJavadoc</a> check.
</p>
<p>
The <a href="https://docs.oracle.com/en/java/javase/11/docs/specs/doc-comment-spec.html">
Documentation Comment Specification</a> permits leading asterisks on the first line.
For these Javadoc comments:
</p>
<source>
/***
* Some text.
*/
/************
* Some text.
*/
/** **
* Some text.
*/
</source>
<p>
The documentation generated will be just "Some text." without any asterisks.
Since these asterisks will not appear in the generated documentation,
they should not be considered as the beginning of the Javadoc content.
In such cases, the check assumes that the Javadoc content begins on the second line.
</p>
</subsection>
<subsection name="Properties" id="JavadocContentLocation_Properties">
<div class="wrapper">
<table>
<tr>
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
<th>since</th>
</tr>
<tr>
<td>location</td>
<td>Specify the policy on placement of the Javadoc content.</td>
<td>
<a href="property_types.html#JavadocContentLocationOption">
JavadocContentLocationOption</a>
</td>
<td><code>second_line</code></td>
<td>8.27</td>
</tr>
</table>
</div>
</subsection>
<subsection name="Examples" id="JavadocContentLocation_Examples">
<p>
To configure the default check to validate that the Javadoc content starts from the
second line:
</p>
<source>
<module name="JavadocContentLocationCheck"/>
</source>
<p>
This setting produces a violation for each multi-line comment
starting on the same line as the initial asterisks:
</p>
<source>
/** This comment causes a violation because it starts from the first line
* and spans several lines.
*/
/**
* This comment is OK because it starts from the second line.
*/
/** This comment is OK because it is on the single-line. */
</source>
<p>
To ensure that Javadoc content starts from the first line:
</p>
<source>
<module name="JavadocContentLocationCheck">
<property name="location" value="first_line"/>
</module>
</source>
<p>
This setting produces a violation for each comment not
starting on the same line as the initial asterisks:
</p>
<source>
/** This comment is OK because it starts on the first line.
* There may be additional text.
*/
/**
* This comment causes a violation because it starts on the second line.
*/
/** This single-line comment also is OK. */
</source>
</subsection>
<subsection name="Example of Usage" id="JavadocContentLocation_Example_of_Usage">
<ul>
<li>
<a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+JavadocContentLocation">
Checkstyle Style</a>
</li>
</ul>
</subsection>
<subsection name="Violation Messages" id="JavadocContentLocation_Violation_Messages">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fjavadoc+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22javadoc.content.first.line%22">
javadoc.content.first.line</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fjavadoc+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22javadoc.content.second.line%22">
javadoc.content.second.line</a>
</li>
</ul>
<p>
All messages can be customized if the default message doesn't suit you.
Please <a href="config.html#Custom_messages">see the documentation</a> to learn how to.
</p>
</subsection>
<subsection name="Package" id="JavadocContentLocation_Package">
<p>
com.puppycrawl.tools.checkstyle.checks.javadoc
</p>
</subsection>
<subsection name="Parent Module" id="JavadocContentLocation_Parent_Module">
<p>
<a href="config.html#TreeWalker">TreeWalker</a>
</p>
</subsection>
</section>
<section name="JavadocMethod">
<p>Since Checkstyle 3.0</p>
<subsection name="Description" id="JavadocMethod_Description">
<p>
Checks the Javadoc of a method or constructor.
</p>
<p>
Violates parameters and type parameters
for which no param tags are
present can be suppressed by defining property
<code>allowMissingParamTags</code>.
</p>
<p>
Violates methods which return non-void but for which no return tag is
present can be suppressed by defining property
<code>allowMissingReturnTag</code>.
</p>
<p>
Violates exceptions which are declared to be thrown (by <code>throws</code> in the method
signature or by <code>throw new</code> in the method body), but for which no throws tag is
present by activation of property <code>validateThrows</code>.
Note that <code>throw new</code> is not checked in the following places:
</p>
<ul>
<li>
Inside a try block (with catch). It is not possible to determine if the thrown
exception can be caught by the catch block as there is no knowledge of the
inheritance hierarchy, so the try block is ignored entirely. However, catch
and finally blocks, as well as try blocks without catch, are still checked.
</li>
<li>
Local classes, anonymous classes and lambda expressions. It is not known when the
throw statements inside such classes are going to be evaluated, so they are ignored.
</li>
</ul>
<p>
ATTENTION: Checkstyle does not have information about hierarchy of exception types
so usage of base class is considered as separate exception type.
As workaround, you need to specify both types in javadoc (parent and exact type).
</p>
<p>
Javadoc is not required on a method that is tagged with the
<code>@Override</code> annotation. However, under
Java 5 it is not possible to mark a method required for an
interface (this was <i>corrected</i> under Java 6). Hence,
Checkstyle supports using the convention of using a single
<code>{@inheritDoc}</code> tag instead of all the
other tags.
</p>
<p>
Note that only inheritable items will allow the
<code>{@inheritDoc}</code> tag to be used in place
of comments. Static methods at all visibilities, private non-static
methods and constructors are not inheritable.
</p>
<p>
For example, if the following method is
implementing a method required by an interface, then the
Javadoc could be done as:
</p>
<source>
/** {@inheritDoc} */
public int checkReturnTag(final int aTagIndex,
JavadocTag[] aTags,
int aLineNo)
</source>
</subsection>
<subsection name="Properties" id="JavadocMethod_Properties">
<div class="wrapper">
<table>
<tr>
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
<th>since</th>
</tr>
<tr>
<td>allowedAnnotations</td>
<td>Specify annotations that allow missed documentation.</td>
<td><a href="property_types.html#String.5B.5D">String[]</a></td>
<td><code>Override</code></td>
<td>6.0</td>
</tr>
<tr>
<td>validateThrows</td>
<td>Control whether to validate <code>throws</code> tags.</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><code>false</code></td>
<td>6.0</td>
</tr>
<tr>
<td>accessModifiers</td>
<td>Specify the access modifiers where Javadoc comments are checked.</td>
<td><a href="property_types.html#AccessModifierOption.5B.5D">AccessModifierOption[]
</a></td>
<td><code>public, protected, package, private</code></td>
<td>8.42</td>
</tr>
<tr>
<td>allowMissingParamTags</td>
<td>Control whether to ignore violations when a method has parameters
but does not have matching <code>param</code> tags in the javadoc.</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><code>false</code></td>
<td>3.1</td>
</tr>
<tr>
<td>allowMissingReturnTag</td>
<td>Control whether to ignore violations when a method returns
non-void type and does not have a <code>return</code> tag in the javadoc.</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><code>false</code></td>
<td>3.1</td>
</tr>
<tr>
<td>tokens</td>
<td>tokens to check</td>
<td>
subset of tokens
<a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">
METHOD_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">
CTOR_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ANNOTATION_FIELD_DEF">
ANNOTATION_FIELD_DEF</a>
,<a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#COMPACT_CTOR_DEF">
COMPACT_CTOR_DEF</a>
.
</td>
<td>
<a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">
METHOD_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">
CTOR_DEF</a>
, <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ANNOTATION_FIELD_DEF">
ANNOTATION_FIELD_DEF</a>
,<a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#COMPACT_CTOR_DEF">
COMPACT_CTOR_DEF</a>
.
</td>
<td>3.0</td>
</tr>
</table>
</div>
</subsection>
<subsection name="Examples" id="JavadocMethod_Examples">
<p>
To configure the default check:
</p>
<source>
<module name="JavadocMethod"/>
</source>
<p>
To configure the check for only <code>public</code>
modifier, ignoring any missing param tags is:
</p>
<source>
<module name="JavadocMethod">
<property name="accessModifiers" value="public"/>
<property name="allowMissingParamTags" value="true"/>
</module>
</source>
<p>
To configure the check for methods which are in <code>private</code>
and <code>package</code>, but not any other modifier:
</p>
<source>
<module name="JavadocMethod">
<property name="accessModifiers" value="private, package"/>
</module>
</source>
<p>
To configure the check to validate <code>throws</code> tags, you can use following config.
</p>
<source>
<module name="JavadocMethod">
<property name="validateThrows" value="true"/>
</module>
</source>
<source>
/**
* Actual exception thrown is child class of class that is declared in throws.
* It is limitation of checkstyle (as checkstyle does not know type hierarchy).
* Javadoc is valid not declaring FileNotFoundException
* BUT checkstyle can not distinguish relationship between exceptions.
* @param file some file
* @throws IOException if some problem
*/
public void doSomething8(File file) throws IOException {
if (file == null) {
throw new FileNotFoundException(); // violation
}
}
/**
* Exact throw type referencing in javadoc even first is parent of second type.
* It is a limitation of checkstyle (as checkstyle does not know type hierarchy).
* This javadoc is valid for checkstyle and for javadoc tool.
* @param file some file
* @throws IOException if some problem
* @throws FileNotFoundException if file is not found
*/
public void doSomething9(File file) throws IOException {
if (file == null) {
throw new FileNotFoundException();
}
}
/**
* Ignore try block, but keep catch and finally blocks.
*
* @param s String to parse
* @return A positive integer
*/
public int parsePositiveInt(String s) {
try {
int value = Integer.parseInt(s);
if (value <= 0) {
throw new NumberFormatException(value + " is negative/zero"); // ok, try
}
return value;
} catch (NumberFormatException ex) {
throw new IllegalArgumentException("Invalid number", ex); // violation, catch
} finally {
throw new IllegalStateException("Should never reach here"); // violation, finally
}
}
/**
* Try block without catch is not ignored.
*
* @return a String from standard input, if there is one
*/
public String readLine() {
try (Scanner sc = new Scanner(System.in)) {
if (!sc.hasNext()) {
throw new IllegalStateException("Empty input"); // violation, not caught
}
return sc.next();
}
}
/**
* Lambda expressions are ignored as we do not know when the exception will be thrown.
*
* @param s a String to be printed at some point in the future
* @return a Runnable to be executed when the string is to be printed
*/
public Runnable printLater(String s) {
return () -> {
if (s == null) {
throw new NullPointerException(); // ok
}
System.out.println(s);
};
}
</source>
</subsection>
<subsection name="Example of Usage" id="JavadocMethod_Example_of_Usage">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Agoogle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+JavadocMethod">
Google Style</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Asun_checks.xml+repo%3Acheckstyle%2Fcheckstyle+JavadocMethod">
Sun Style</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+JavadocMethod">
Checkstyle Style</a>
</li>
</ul>
</subsection>
<subsection name="Violation Messages" id="JavadocMethod_Violation_Messages">
<ul>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fjavadoc+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22javadoc.classInfo%22">
javadoc.classInfo</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fjavadoc+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22javadoc.duplicateTag%22">
javadoc.duplicateTag</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fjavadoc+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22javadoc.expectedTag%22">
javadoc.expectedTag</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fjavadoc+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22javadoc.invalidInheritDoc%22">
javadoc.invalidInheritDoc</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fjavadoc+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22javadoc.return.expected%22">
javadoc.return.expected</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fjavadoc+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22javadoc.unusedTag%22">
javadoc.unusedTag</a>
</li>
<li>
<a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fjavadoc+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22javadoc.unusedTagGeneral%22">
javadoc.unusedTagGeneral</a>
</li>
</ul>
<p>
All messages can be customized if the default message doesn't suit you.
Please <a href="config.html#Custom_messages">see the documentation</a> to learn how to.
</p>
</subsection>
<subsection name="Package" id="JavadocMethod_Package">
<p>
com.puppycrawl.tools.checkstyle.checks.javadoc
</p>
</subsection>
<subsection name="Parent Module" id="JavadocMethod_Parent_Module">
<p>
<a href="config.html#TreeWalker">TreeWalker</a>
</p>
</subsection>
</section>
<section name="JavadocMissingLeadingAsterisk">
<p>Since Checkstyle 8.38</p>
<subsection name="Description" id="JavadocMissingLeadingAsterisk_Description">
<p>
Checks if the javadoc has
<a href="https://docs.oracle.com/en/java/javase/14/docs/specs/javadoc/doc-comment-spec.html#leading-asterisks">
leading asterisks
</a>
on each line.
</p>
<p>
The check does not require asterisks on the first line, nor on the last line
if it is blank. All other lines in a Javadoc should start with <code>*</code>,
including blank lines and code blocks.
</p>
</subsection>
<subsection name="Properties" id="JavadocMissingLeadingAsterisk_Properties">
<div class="wrapper">
<table>
<tr>
<th>name</th>
<th>description</th>
<th>type</th>
<th>default value</th>
<th>since</th>
</tr>
<tr>
<td>violateExecutionOnNonTightHtml</td>
<td>
Control when to print violations if the Javadoc being examined by this check
violates the tight html rules defined at
<a href="writingjavadocchecks.html#Tight-HTML_rules">Tight-HTML Rules</a>.
</td>
<td><a href="property_types.html#boolean">boolean</a></td>
<td><code>false</code></td>
<td>8.38</td>
</tr>
</table>
</div>
</subsection>
<subsection name="Examples" id="JavadocMissingLeadingAsterisk_Examples">
<p>
To configure the check:
</p>
<source>
<module name="JavadocMissingLeadingAsterisk"/>
</source>