Skip to content

Commit

Permalink
supplemental: added violation messages in JavadocParagraph's input files
Browse files Browse the repository at this point in the history
  • Loading branch information
Zopsss authored and romani committed Sep 27, 2024
1 parent 82bc795 commit 4c378dc
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 58 deletions.
2 changes: 2 additions & 0 deletions config/checkstyle-resources-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@
files="[\\/]test[\\/]resources[\\/]com[\\/]puppycrawl[\\/]tools[\\/]checkstyle[\\/]checks[\\/]javadoc[\\/]javadocmethod[\\/]InputJavadocMethodPublicOnly1\.java"/>
<suppress checks="FileLength"
files="[\\/]test[\\/]resources[\\/]com[\\/]puppycrawl[\\/]tools[\\/]checkstyle[\\/]checks[\\/]javadoc[\\/]javadocmethod[\\/]InputJavadocMethodProtectedScopeJavadoc\.java"/>
<suppress checks="FileLength"
files="[\\/]test[\\/]resources[\\/]com[\\/]puppycrawl[\\/]tools[\\/]checkstyle[\\/]checks[\\/]javadoc[\\/]javadocparagraph[\\/]InputJavadocParagraphIncorrect\.java"/>
<suppress checks="FileLength"
files="[\\/]test[\\/]resources[\\/]com[\\/]puppycrawl[\\/]tools[\\/]checkstyle[\\/]checks[\\/]javadoc[\\/]javadoctype[\\/]InputJavadocTypePublicOnly1\.java"/>
<suppress checks="FileLength"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,42 +58,42 @@ public void testCorrect() throws Exception {
@Test
public void testIncorrect() throws Exception {
final String[] expected = {
"13: " + getCheckMessage(MSG_MISPLACED_TAG),
"13: " + getCheckMessage(MSG_LINE_BEFORE),
"14: " + getCheckMessage(MSG_MISPLACED_TAG),
"14: " + getCheckMessage(MSG_LINE_BEFORE),
"20: " + getCheckMessage(MSG_MISPLACED_TAG),
"20: " + getCheckMessage(MSG_LINE_BEFORE),
"22: " + getCheckMessage(MSG_MISPLACED_TAG),
"30: " + getCheckMessage(MSG_LINE_BEFORE),
"32: " + getCheckMessage(MSG_MISPLACED_TAG),
"39: " + getCheckMessage(MSG_MISPLACED_TAG),
"16: " + getCheckMessage(MSG_MISPLACED_TAG),
"16: " + getCheckMessage(MSG_LINE_BEFORE),
"17: " + getCheckMessage(MSG_MISPLACED_TAG),
"17: " + getCheckMessage(MSG_LINE_BEFORE),
"29: " + getCheckMessage(MSG_MISPLACED_TAG),
"29: " + getCheckMessage(MSG_LINE_BEFORE),
"31: " + getCheckMessage(MSG_MISPLACED_TAG),
"39: " + getCheckMessage(MSG_LINE_BEFORE),
"39: " + getCheckMessage(MSG_REDUNDANT_PARAGRAPH),
"40: " + getCheckMessage(MSG_MISPLACED_TAG),
"40: " + getCheckMessage(MSG_LINE_BEFORE),
"41: " + getCheckMessage(MSG_MISPLACED_TAG),
"41: " + getCheckMessage(MSG_LINE_BEFORE),
"42: " + getCheckMessage(MSG_MISPLACED_TAG),
"42: " + getCheckMessage(MSG_LINE_BEFORE),
"46: " + getCheckMessage(MSG_MISPLACED_TAG),
"46: " + getCheckMessage(MSG_LINE_BEFORE),
"52: " + getCheckMessage(MSG_MISPLACED_TAG),
"52: " + getCheckMessage(MSG_REDUNDANT_PARAGRAPH),
"55: " + getCheckMessage(MSG_MISPLACED_TAG),
"55: " + getCheckMessage(MSG_LINE_BEFORE),
"55: " + getCheckMessage(MSG_REDUNDANT_PARAGRAPH),
"56: " + getCheckMessage(MSG_MISPLACED_TAG),
"56: " + getCheckMessage(MSG_LINE_BEFORE),
"57: " + getCheckMessage(MSG_MISPLACED_TAG),
"57: " + getCheckMessage(MSG_LINE_BEFORE),
"58: " + getCheckMessage(MSG_MISPLACED_TAG),
"58: " + getCheckMessage(MSG_LINE_BEFORE),
"69: " + getCheckMessage(MSG_REDUNDANT_PARAGRAPH),
"70: " + getCheckMessage(MSG_TAG_AFTER),
"79: " + getCheckMessage(MSG_MISPLACED_TAG),
"79: " + getCheckMessage(MSG_LINE_BEFORE),
"81: " + getCheckMessage(MSG_MISPLACED_TAG),
"84: " + getCheckMessage(MSG_MISPLACED_TAG),
"84: " + getCheckMessage(MSG_LINE_BEFORE),
"91: " + getCheckMessage(MSG_TAG_AFTER),
"92: " + getCheckMessage(MSG_TAG_AFTER),
"71: " + getCheckMessage(MSG_MISPLACED_TAG),
"71: " + getCheckMessage(MSG_LINE_BEFORE),
"80: " + getCheckMessage(MSG_MISPLACED_TAG),
"80: " + getCheckMessage(MSG_REDUNDANT_PARAGRAPH),
"83: " + getCheckMessage(MSG_MISPLACED_TAG),
"85: " + getCheckMessage(MSG_MISPLACED_TAG),
"85: " + getCheckMessage(MSG_LINE_BEFORE),
"86: " + getCheckMessage(MSG_MISPLACED_TAG),
"86: " + getCheckMessage(MSG_LINE_BEFORE),
"103: " + getCheckMessage(MSG_REDUNDANT_PARAGRAPH),
"104: " + getCheckMessage(MSG_TAG_AFTER),
"116: " + getCheckMessage(MSG_MISPLACED_TAG),
"116: " + getCheckMessage(MSG_LINE_BEFORE),
"118: " + getCheckMessage(MSG_MISPLACED_TAG),
"121: " + getCheckMessage(MSG_MISPLACED_TAG),
"121: " + getCheckMessage(MSG_LINE_BEFORE),
"131: " + getCheckMessage(MSG_TAG_AFTER),
"132: " + getCheckMessage(MSG_TAG_AFTER),
};
verifyWithInlineConfigParser(
getPath("InputJavadocParagraphIncorrect.java"), expected);
Expand All @@ -106,21 +106,21 @@ public void testAllowNewlineParagraph() throws Exception {
"14: " + getCheckMessage(MSG_LINE_BEFORE),
"19: " + getCheckMessage(MSG_LINE_BEFORE),
"28: " + getCheckMessage(MSG_LINE_BEFORE),
"37: " + getCheckMessage(MSG_LINE_BEFORE),
"37: " + getCheckMessage(MSG_REDUNDANT_PARAGRAPH),
"38: " + getCheckMessage(MSG_LINE_BEFORE),
"39: " + getCheckMessage(MSG_LINE_BEFORE),
"40: " + getCheckMessage(MSG_LINE_BEFORE),
"45: " + getCheckMessage(MSG_LINE_BEFORE),
"53: " + getCheckMessage(MSG_REDUNDANT_PARAGRAPH),
"58: " + getCheckMessage(MSG_LINE_BEFORE),
"59: " + getCheckMessage(MSG_LINE_BEFORE),
"70: " + getCheckMessage(MSG_REDUNDANT_PARAGRAPH),
"71: " + getCheckMessage(MSG_TAG_AFTER),
"80: " + getCheckMessage(MSG_LINE_BEFORE),
"85: " + getCheckMessage(MSG_LINE_BEFORE),
"93: " + getCheckMessage(MSG_TAG_AFTER),
"94: " + getCheckMessage(MSG_TAG_AFTER),
"40: " + getCheckMessage(MSG_REDUNDANT_PARAGRAPH),
"41: " + getCheckMessage(MSG_LINE_BEFORE),
"42: " + getCheckMessage(MSG_LINE_BEFORE),
"43: " + getCheckMessage(MSG_LINE_BEFORE),
"48: " + getCheckMessage(MSG_LINE_BEFORE),
"56: " + getCheckMessage(MSG_REDUNDANT_PARAGRAPH),
"61: " + getCheckMessage(MSG_LINE_BEFORE),
"62: " + getCheckMessage(MSG_LINE_BEFORE),
"73: " + getCheckMessage(MSG_REDUNDANT_PARAGRAPH),
"74: " + getCheckMessage(MSG_TAG_AFTER),
"83: " + getCheckMessage(MSG_LINE_BEFORE),
"88: " + getCheckMessage(MSG_LINE_BEFORE),
"96: " + getCheckMessage(MSG_TAG_AFTER),
"97: " + getCheckMessage(MSG_TAG_AFTER),
};
verifyWithInlineConfigParser(
getPath("InputJavadocParagraphIncorrect2.java"), expected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class Check {
* Checks whether file contains code. Files which are considered to have no code:
* </p>
* <p>
*/ // 2 violations above
*/
// 2 violations 2 lines above:
// '\<p\> tag should be placed immediately before the first word'
// '\<p\> tag should be preceded with an empty line.'
void inheritDocWithThrows() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,25 @@

package com.puppycrawl.tools.checkstyle.checks.javadoc.javadocparagraph;

// 2 violations 5 lines below:
// 'tag should be placed immediately before the first word'
// 'tag should be preceded with an empty line.'
/**
* Some Javadoc. // 2 violations below
* Some Javadoc.
* <p>
* /^ WARN/ Some Javadoc.<p> // 2 violations
* /^ WARN/ Some Javadoc.<p>
*
*/
// 2 violations 3 lines above:
// 'tag should be placed immediately before the first word'
// 'tag should be preceded with an empty line.'
class InputJavadocParagraphIncorrect {

// 2 violations 4 lines below:
// 'tag should be placed immediately before the first word'
// 'tag should be preceded with an empty line.'
/**
* Some Javadoc.<P> // 2 violations
* Some Javadoc.<P>
*
* <p> Some Javadoc. // violation 'tag should be placed immediately before the first word'
*
Expand All @@ -36,29 +45,54 @@ class InputJavadocParagraphIncorrect {
*/
boolean emulated() {return false;}

/**<p>Some Javadoc.<p> // 3 violations
* <p> // 2 violations
* <p><p> // 2 violations
* <p>/^WARN/ Some Javadoc.<p>*/ // 2 violations
// 3 violations 7 lines below:
// 'tag should be placed immediately before the first word'
// 'tag should be preceded with an empty line.'
// 'Redundant <p> tag.'
// 2 violations 4 lines below:
// 'tag should be placed immediately before the first word'
// 'tag should be preceded with an empty line.'
/**<p>Some Javadoc.<p>
* <p>
* <p><p>
* <p>/^WARN/ Some Javadoc.<p>*/
// 2 violations 2 lines above:
// 'tag should be placed immediately before the first word'
// 'tag should be preceded with an empty line.'
// 2 violations 4 lines above:
// 'tag should be placed immediately before the first word'
// 'tag should be preceded with an empty line.'
class InnerInputJavadocParagraphIncorrect {

// 2 violations 4 lines below:
// 'tag should be placed immediately before the first word'
// 'tag should be preceded with an empty line.'
/**
* Some Javadoc./WARN/<p> // 2 violations
* Some Javadoc./WARN/<p>
*
* @since 8.0
*/
public static final byte NUL = 0;

// 2 violations 3 lines below:
// 'tag should be placed immediately before the first word'
// 'Redundant \<p\> tag.'
/**<p>
* /^WARN/ Some Javadoc. // 2 violations above
* /^WARN/ Some Javadoc.
*
* <P> // violation 'tag should be placed immediately before the first word'
* /^WARN/
* <p> // 2 violations
* /^WARN/ Some Javadoc.<p> // 2 violations
* <p>
* /^WARN/ Some Javadoc.<p>
* @see <a href="http://www.gwtproject.org/doc/latest/DevGuideOrganizingProjects.html#DevGuideModules">
* Documentation about GWT emulated source</a>
*/
// 2 violations 5 lines above:
// 'tag should be placed immediately before the first word'
// 'tag should be preceded with an empty line.'
// 2 violations 7 lines above:
// 'tag should be placed immediately before the first word'
// 'tag should be preceded with an empty line.'
boolean emulated() {return false;}
}

Expand All @@ -75,14 +109,20 @@ class InnerInputJavadocParagraphIncorrect {
// violation 5 lines above 'Empty line should be followed by <p> tag on the next line.'
public static final byte NUL = 0;

// 2 violations 4 lines below:
// 'tag should be placed immediately before the first word'
// 'tag should be preceded with an empty line.'
/**
* /WARN/ Some Javadoc.<p> // 2 violations
* /WARN/ Some Javadoc.<p>
*
* <p> Some Javadoc. // violation 'tag should be placed immediately before the first word'
*
* @see <a href="http://www.gwtproject.org/doc/latest/DevGuideOrganizingProjects.html#DevGuideModules">
* Documentation about <p> GWT emulated source</a> // 2 violations
* Documentation about <p> GWT emulated source</a>
*/
// 2 violations 2 lines above:
// 'tag should be placed immediately before the first word'
// 'tag should be preceded with an empty line.'
boolean emulated() {return false;}

// violation 3 lines below 'Empty line should be followed by <p> tag on the next line.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ class InputJavadocParagraphIncorrect2 {
*/
boolean emulated() {return false;}

/**<p>Some Javadoc.<p> // 2 violations
// 2 violations 3 lines below:
// 'tag should be preceded with an empty line.'
// 'Redundant \<p\> tag.'
/**<p>Some Javadoc.<p>
* <p> // violation '<p> tag should be preceded with an empty line.'
* <p><p> // violation '<p> tag should be preceded with an empty line.'
* <p>/^WARN/ Some Javadoc.<p>*/
Expand Down

0 comments on commit 4c378dc

Please sign in to comment.