Skip to content

Commit b96d1c3

Browse files
achyuth8055romani
authored andcommitted
Issue #15456: Define violation messages for JavadocTagContinuationIndentation
1 parent d47cde5 commit b96d1c3

14 files changed

Lines changed: 193 additions & 151 deletions

src/site/xdoc/checks/javadoc/javadoctagcontinuationindentation.xml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ class Example1 {
101101
* Writes the object using a
102102
* <a href="{@docRoot}/serialized-form.html#java.time.Ser">dedicated form</a>.
103103
* @serialData
104-
* <code> // violation
105-
* out.writeByte(1); // violation
106-
* out.writeInt(nanos); // violation
107-
* </code> // violation
104+
* <code> // violation 'expected level should be 4'
105+
* out.writeByte(1); // violation 'expected level should be 4'
106+
* out.writeInt(nanos); // violation 'expected level should be 4'
107+
* </code> // violation 'expected level should be 4'
108108
*/
109109
public void testMethodCode(String input) {}
110110

@@ -164,10 +164,10 @@ class Example2 {
164164
* Writes the object using a
165165
* <a href="{@docRoot}/serialized-form.html#java.time.Ser">dedicated form</a>.
166166
* @serialData
167-
* <code> // violation
168-
* out.writeByte(1); // violation
169-
* out.writeInt(nanos); // violation
170-
* </code> // violation
167+
* <code> // violation 'expected level should be 2'
168+
* out.writeByte(1); // violation 'expected level should be 2'
169+
* out.writeInt(nanos); // violation 'expected level should be 2'
170+
* </code> // violation 'expected level should be 2'
171171
*/
172172
public void testMethodCode(String input) {}
173173

@@ -228,10 +228,10 @@ class Example3 {
228228
* Writes the object using a
229229
* <a href="{@docRoot}/serialized-form.html#java.time.Ser">dedicated form</a>.
230230
* @serialData
231-
* <code> // violation
232-
* out.writeByte(1); // violation
233-
* out.writeInt(nanos); // violation
234-
* </code> // violation
231+
* <code> // violation 'expected level should be 4'
232+
* out.writeByte(1); // violation 'expected level should be 4'
233+
* out.writeInt(nanos); // violation 'expected level should be 4'
234+
* </code> // violation 'expected level should be 4'
235235
*/
236236
public void testMethodCode(String input) {}
237237

src/test/java/com/puppycrawl/tools/checkstyle/bdd/InlineConfigParser.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,6 @@ public final class InlineConfigParser {
246246
"com.puppycrawl.tools.checkstyle.checks.javadoc.AtclauseOrderCheck",
247247
"com.puppycrawl.tools.checkstyle.checks.javadoc.InvalidJavadocPositionCheck",
248248
"com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocBlockTagLocationCheck",
249-
"com.puppycrawl.tools.checkstyle.checks.javadoc"
250-
+ ".JavadocTagContinuationIndentationCheck",
251249
"com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck",
252250
"com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck",
253251
"com.puppycrawl.tools.checkstyle.checks.javadoc"

src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheckTest.java

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,6 @@ public void testBlockTag() throws Exception {
114114
"62: " + getCheckMessage(MSG_KEY, 4),
115115
"74: " + getCheckMessage(MSG_KEY, 4),
116116
"75: " + getCheckMessage(MSG_KEY, 4),
117-
"86: " + getCheckMessage(MSG_KEY, 4),
118-
"87: " + getCheckMessage(MSG_KEY, 4),
119-
"88: " + getCheckMessage(MSG_KEY, 4),
120117
"89: " + getCheckMessage(MSG_KEY, 4),
121118
"90: " + getCheckMessage(MSG_KEY, 4),
122119
"91: " + getCheckMessage(MSG_KEY, 4),
@@ -128,8 +125,11 @@ public void testBlockTag() throws Exception {
128125
"97: " + getCheckMessage(MSG_KEY, 4),
129126
"98: " + getCheckMessage(MSG_KEY, 4),
130127
"99: " + getCheckMessage(MSG_KEY, 4),
131-
"104: " + getCheckMessage(MSG_KEY, 4),
132-
"105: " + getCheckMessage(MSG_KEY, 4),
128+
"100: " + getCheckMessage(MSG_KEY, 4),
129+
"101: " + getCheckMessage(MSG_KEY, 4),
130+
"102: " + getCheckMessage(MSG_KEY, 4),
131+
"107: " + getCheckMessage(MSG_KEY, 4),
132+
"108: " + getCheckMessage(MSG_KEY, 4),
133133
};
134134
verifyWithInlineConfigParser(
135135
getPath("InputJavadocTagContinuationIndentationBlockTag.java"),
@@ -197,23 +197,31 @@ public void testJavadocTagContinuationIndentationCheckPreTag2() throws Exception
197197
"33: " + getCheckMessage(MSG_KEY, 4),
198198
"34: " + getCheckMessage(MSG_KEY, 4),
199199
"35: " + getCheckMessage(MSG_KEY, 4),
200-
"70: " + getCheckMessage(MSG_KEY, 4),
201-
"78: " + getCheckMessage(MSG_KEY, 4),
202-
"79: " + getCheckMessage(MSG_KEY, 4),
203-
"80: " + getCheckMessage(MSG_KEY, 4),
204-
"81: " + getCheckMessage(MSG_KEY, 4),
205-
"82: " + getCheckMessage(MSG_KEY, 4),
206-
"83: " + getCheckMessage(MSG_KEY, 4),
207-
"84: " + getCheckMessage(MSG_KEY, 4),
208-
"85: " + getCheckMessage(MSG_KEY, 4),
209-
"90: " + getCheckMessage(MSG_KEY, 4),
210-
"91: " + getCheckMessage(MSG_KEY, 4),
211-
"92: " + getCheckMessage(MSG_KEY, 4),
212200
};
213201
verifyWithInlineConfigParser(
214202
getPath("InputJavadocTagContinuationIndentationPreTag2.java"), expected);
215203
}
216204

205+
@Test
206+
public void testJavadocTagContinuationIndentationCheckPreTag2Two() throws Exception {
207+
final String[] expected = {
208+
"23: " + getCheckMessage(MSG_KEY, 4),
209+
"31: " + getCheckMessage(MSG_KEY, 4),
210+
"32: " + getCheckMessage(MSG_KEY, 4),
211+
"33: " + getCheckMessage(MSG_KEY, 4),
212+
"34: " + getCheckMessage(MSG_KEY, 4),
213+
"35: " + getCheckMessage(MSG_KEY, 4),
214+
"36: " + getCheckMessage(MSG_KEY, 4),
215+
"37: " + getCheckMessage(MSG_KEY, 4),
216+
"38: " + getCheckMessage(MSG_KEY, 4),
217+
"43: " + getCheckMessage(MSG_KEY, 4),
218+
"44: " + getCheckMessage(MSG_KEY, 4),
219+
"45: " + getCheckMessage(MSG_KEY, 4),
220+
};
221+
verifyWithInlineConfigParser(
222+
getPath("InputJavadocTagContinuationIndentationPreTag2Two.java"), expected);
223+
}
224+
217225
@Test
218226
public void testJavadocTagContinuationIndentationCheckPreTag3() throws Exception {
219227
final String[] expected = {

src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/InputJavadocTagContinuationIndentation.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class InputJavadocTagContinuationIndentation implements Serializable
5252
* @return Some text.
5353
* @serialData Some javadoc.
5454
* @see Some text.
55-
* Some javadoc. // violation
55+
* Some javadoc. // violation, 'Line continuation .* expected level should be 4'
5656
* @throws Exception Some text.
5757
*/
5858
String method(String aString) throws Exception
@@ -114,10 +114,10 @@ String method5(String aString)
114114
* Some text.
115115
* @param aString Some text.
116116
* @return Some text.
117-
* Some javadoc. // violation
117+
* Some javadoc. // violation, 'Line continuation .* expected level should be 4'
118118
* @serialData Some javadoc.
119119
* @param aInt Some text.
120-
* Some javadoc. // violation
120+
* Some javadoc. // violation, 'Line continuation .* expected level should be 4'
121121
* @throws Exception Some text.
122122
* @param aBoolean Some text.
123123
* @see Some text.
@@ -208,10 +208,10 @@ String method5(String aString)
208208
* @param aString Some text.
209209
* @return Some text.
210210
* @param aInt Some text.
211-
* Some javadoc. // violation
211+
* Some javadoc. // violation, 'Line continuation .* expected level should be 4'
212212
* @throws Exception Some text.
213213
* @param aBoolean Some text.
214-
* Some javadoc. // violation
214+
* Some javadoc. // violation, 'Line continuation .* expected level should be 4'
215215
* @see Some text.
216216
*/
217217
String method6(String aString, int aInt, boolean aBoolean) throws Exception
@@ -226,9 +226,9 @@ String method6(String aString, int aInt, boolean aBoolean) throws Exception
226226
* Some text.
227227
* @throws Exception Some text.
228228
* @param aString Some text.
229-
* Some javadoc. // violation
229+
* Some javadoc. // violation, 'Line continuation .* expected level should be 4'
230230
* @serialData Some javadoc.
231-
* Some javadoc. // violation
231+
* Some javadoc. // violation, 'Line continuation .* expected level should be 4'
232232
* @see Some text.
233233
* @return Some text.
234234
*/
@@ -290,12 +290,12 @@ String method5(String aString)
290290
* Some text.
291291
* Some javadoc.
292292
* @param aString Some text.
293-
* Some javadoc. // violation
293+
* Some javadoc. // violation, 'Line continuation .* expected level should be 4'
294294
* @return Some text.
295295
* @param aInt Some text.
296-
* Some javadoc. // violation
296+
* Some javadoc. // violation, 'Line continuation .* expected level should be 4'
297297
* @throws Exception Some text.
298-
* Some javadoc. // violation
298+
* Some javadoc. // violation, 'Line continuation .* expected level should be 4'
299299
* @param aBoolean Some text.
300300
* @see Some text.
301301
*/
@@ -315,7 +315,7 @@ String method6(String aString, int aInt, boolean aBoolean) throws Exception
315315
* Some javadoc.
316316
* Some javadoc.
317317
* @see Some javadoc.
318-
* Some javadoc. // violation
318+
* Some javadoc. // violation, 'Line continuation .* expected level should be 4'
319319
* @author max
320320
*/
321321
enum Foo1 {}
@@ -327,9 +327,9 @@ enum Foo1 {}
327327
* @since Some javadoc.
328328
* Some javadoc.
329329
* @serialData Some javadoc.
330-
* Line below is empty on purpose. // violation
331-
* @see Some Text.
332-
* L. // violation
330+
* Line below is empty on purpose.
331+
* @see Some Text. // violation above 'Line continuation .* expected level should be 4'
332+
* L. // violation, 'Line continuation .* expected level should be 4'
333333
*
334334
* @author max
335335
* @customTag {@link com.puppycrawl.tools.checkstyle.AllChecksPresentOnAvailableChecksPageTest
@@ -347,7 +347,7 @@ class ShortNextLine {
347347
* Test.
348348
*
349349
* @return Test
350-
* tt <code>null</code>. // violation
350+
* tt <code>null</code>. // violation, 'Line continuation .* expected level should be 4'
351351
*/
352352
public void example() {
353353
}

src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/InputJavadocTagContinuationIndentationBlockTag.java

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class InputJavadocTagContinuationIndentationBlockTag {
1818
* type. Returns 0 for types other than float, double, int, and long.
1919
* @param text the string to be parsed.
2020
* @param type the token type of the text. Should be a constant of
21-
* {@link TokenTypes}. // violation
21+
* {@link TokenTypes}. // violation, 'Line continuation .* expected level should be 4'
2222
* @return the double value represented by the string argument.
2323
*/
2424
public static double parseDouble(String text, int type) {
@@ -29,8 +29,8 @@ public static double parseDouble(String text, int type) {
2929
* Javadoc.
3030
*
3131
* @param x this line is normal
32-
* {@code this} line is wrongly indented // violation
33-
*/
32+
* {@code this} line is wrongly indented
33+
*/ // violation above 'Line continuation .* expected level should be 4'
3434
public void newlineThenBlockTag(int x) {
3535
// do stuff
3636
}
@@ -39,8 +39,8 @@ public void newlineThenBlockTag(int x) {
3939
* Not enough indentation.
4040
*
4141
* @param x this line is normal
42-
* {@code this} line is wrongly indented // violation
43-
*/
42+
* {@code this} line is wrongly indented
43+
*/ // violation above 'Line continuation .* expected level should be 4'
4444
public void partialIndent(int x) {
4545
// do stuff
4646
}
@@ -59,8 +59,8 @@ public int identity(int x) {
5959
* Javadoc.
6060
*
6161
* @param args
62-
* {@code this} line is not correctly indented // violation
63-
* {@code this}
62+
* {@code this} line is not correctly indented
63+
* {@code this} // violation above 'Line continuation .* expected level should be 4'
6464
* <pre>pre tags are skipped</pre>
6565
*/
6666
public void multipleLines1(String args) {
@@ -71,40 +71,43 @@ public void multipleLines1(String args) {
7171
* Javadoc.
7272
*
7373
* @return false always
74-
* {@code this} line is not correctly indented // violation
75-
* {@code this} line is not correctly indented // violation
74+
* {@code this} line is not correctly indented
75+
* {@code this} line is not correctly indented
7676
* <pre>pre tags are skipped</pre>
7777
*/
7878
public boolean isMultipleLines2() {
7979
return false;
8080
}
81+
// violation 7 lines above 'Line continuation .* expected level should be 4'
82+
// violation 7 lines above 'Line continuation .* expected level should be 4'
83+
// violation 6 lines below 'Line continuation .* expected level should be 4'
8184

8285
/**
8386
* Javadoc from regression test case (apache-ant).
84-
*
87+
* // violation 3 lines below 'Line continuation .* expected level should be 4'
8588
* @param c the command line which will be configured
86-
* if the commandline is initially null, the function is a noop // violation
87-
* otherwise the function append to the commandline arguments concerning // violation
88-
* <ul> // violation
89-
* <li> // violation
90-
* cvs package // violation
91-
* </li> // violation
92-
* <li> // violation
93-
* compression // violation
94-
* </li> // violation
95-
* <li> // violation
96-
* quiet or reallyquiet // violation
97-
* </li> // violation
98-
* <li>cvsroot</li> // violation
99-
* <li>noexec</li> // violation
89+
* if the commandline is initially null, the function is a noop
90+
* otherwise the function append to the commandline arguments concerning
91+
* <ul> // violation, 'Line continuation .* expected level should be 4'
92+
* <li> // violation, 'Line continuation .* expected level should be 4'
93+
* cvs package // violation, 'Line continuation .* expected level should be 4'
94+
* </li> // violation, 'Line continuation .* expected level should be 4'
95+
* <li> // violation, 'Line continuation .* expected level should be 4'
96+
* compression // violation, 'Line continuation .* expected level should be 4'
97+
* </li> // violation, 'Line continuation .* expected level should be 4'
98+
* <li> // violation, 'Line continuation .* expected level should be 4'
99+
* quiet or reallyquiet // violation, 'Line continuation .* expected level should be 4'
100+
* </li> // violation, 'Line continuation .* expected level should be 4'
101+
* <li>cvsroot</li> // violation, 'Line continuation .* expected level should be 4'
102+
* <li>noexec</li> // violation, 'Line continuation .* expected level should be 4'
100103
* <li>
101104
* another item
102105
* </li>
103106
* <li> yet another item </li>
104-
* </ul> // violation
105-
* some text <i>word</i> more text. // violation
107+
* </ul> // violation, 'Line continuation .* expected level should be 4'
108+
* some text <i>word</i> more text.
106109
* some text <i>word</i> more text.
107-
*/
110+
*/ // violation 2 lines above 'Line continuation .* expected level should be 4'
108111
public String regressionNestedHtml(CharSequence c) {
109112
return "";
110113
}

src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/InputJavadocTagContinuationIndentationDescription.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ public class InputJavadocTagContinuationIndentationDescription {
1313
* General Description here.
1414
*
1515
* @param s
16-
* Description 1. // violation
17-
* Description 2. // violation
18-
* Description 3. // violation
16+
* Description 1. // violation, 'Line continuation .* expected level should be 4'
17+
* Description 2. // violation, 'Line continuation .* expected level should be 4'
18+
* Description 3. // violation, 'Line continuation .* expected level should be 4'
1919
* Description 4 with extra indentation.
2020
*
2121
*
@@ -43,12 +43,12 @@ public void testWithInlineDescription() {}
4343
public void testWithMissingAsterisk(int x) {}
4444

4545
/**
46-
* @param s
47-
*Description with missing space. // violation
48-
* @param s2
49-
*****Description with multiple asterisk and missing space // violation
50-
***** Description with multiple asterisk and missing space // violation
51-
*/
46+
* @param s // violation below 'Line continuation .* expected level should be 4'
47+
*Description with missing space.
48+
* @param s2 // violation below 'Line continuation .* expected level should be 4'
49+
*****Description with multiple asterisk and missing space
50+
***** Description with multiple asterisk and missing space
51+
*/ // violation above 'Line continuation .* expected level should be 4'
5252
public void testOtherCases(String s, String s2) {}
5353

5454
/**
@@ -71,6 +71,6 @@ public void testWithBlankLine() {}
7171
* >SAX.</a>
7272
*/
7373
public void test() { }
74-
// violation 4 lines above
75-
// violation 4 lines above
74+
// violation 4 lines above 'Line continuation .* expected level should be 4'
75+
// violation 4 lines above 'Line continuation .* expected level should be 4'
7676
}

src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/InputJavadocTagContinuationIndentationOffset3.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Some javadoc.
1313
*
1414
* @since Some javadoc.
15-
* Some javadoc. // violation
15+
* Some javadoc. // violation, 'Line continuation .* expected level should be 3'
1616
* @version 1.0
1717
* @deprecated Some javadoc.
1818
* Some javadoc.
@@ -24,7 +24,7 @@ class InputJavadocTagContinuationIndentationOffset3 {
2424
/**
2525
* The client's first name.
2626
* @serial Some javadoc.
27-
* Some javadoc. // violation
27+
* Some javadoc. // violation, 'Line continuation .* expected level should be 3'
2828
*/
2929
private String fFirstName;
3030

0 commit comments

Comments
 (0)