Skip to content

Commit

Permalink
Issue #11214: Specified violation message in WriteTagCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
Sloent authored and romani committed Apr 22, 2023
1 parent 1db88b8 commit 72f1822
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public final class InlineConfigParser {
"com.puppycrawl.tools.checkstyle.checks.regexp.RegexpCheck",
"com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForInitializerPadCheck",
"com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck",
"com.puppycrawl.tools.checkstyle.checks.javadoc.WriteTagCheck",
"com.puppycrawl.tools.checkstyle.checks.javadoc.SummaryJavadocCheck",
"com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ public void testIgnoreMissing() throws Exception {
}

@Test
public void testRegularEx()
throws Exception {
public void testRegularEx() throws Exception {
final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
verifyWithInlineConfigParser(getPath("InputWriteTagRegularExpression.java"), expected);
}
Expand All @@ -147,14 +146,14 @@ public void testRegularExError() throws Exception {
@Test
public void testEnumsAndAnnotations() throws Exception {
final String[] expected = {
"15: " + getCheckMessage(MSG_WRITE_TAG, "@incomplete",
"This enum needs more code... // violation"),
"19: " + getCheckMessage(MSG_WRITE_TAG, "@incomplete",
"This enum constant needs more code... // violation"),
"25: " + getCheckMessage(MSG_WRITE_TAG, "@incomplete",
"This annotation needs more code... // violation"),
"29: " + getCheckMessage(MSG_WRITE_TAG, "@incomplete",
"This annotation field needs more code... // violation"),
"16: " + getCheckMessage(MSG_WRITE_TAG, "@incomplete",
"This enum needs more code..."),
"21: " + getCheckMessage(MSG_WRITE_TAG, "@incomplete",
"This enum constant needs more code..."),
"28: " + getCheckMessage(MSG_WRITE_TAG, "@incomplete",
"This annotation needs more code..."),
"33: " + getCheckMessage(MSG_WRITE_TAG, "@incomplete",
"This annotation field needs more code..."),
};
verifyWithInlineConfigParser(getPath("InputWriteTagEnumsAndAnnotations.java"), expected);
}
Expand All @@ -172,14 +171,18 @@ public void testWriteTagRecordsAndCompactCtors() throws Exception {
final String[] expected = {
"15: " + getCheckMessage(MSG_MISSING_TAG, "@incomplete"),
"19: " + getCheckMessage(MSG_TAG_FORMAT, "@incomplete", "\\S"),
"26: " + getCheckMessage(MSG_WRITE_TAG, "@incomplete", "// violation"),
"26: " + getCheckMessage(MSG_WRITE_TAG, "@incomplete",
"Failed to recognize 'record' introduced in Java 14."),
"33: " + getCheckMessage(MSG_MISSING_TAG, "@incomplete"),
"37: " + getCheckMessage(MSG_WRITE_TAG, "@incomplete", "// violation"),
"37: " + getCheckMessage(MSG_WRITE_TAG, "@incomplete",
"Failed to recognize 'record' introduced in Java 14."),
"44: " + getCheckMessage(MSG_MISSING_TAG, "@incomplete"),
"48: " + getCheckMessage(MSG_WRITE_TAG, "@incomplete", "// violation"),
"48: " + getCheckMessage(MSG_WRITE_TAG, "@incomplete",
"Failed to recognize 'record' introduced in Java 14."),
"56: " + getCheckMessage(MSG_MISSING_TAG, "@incomplete"),
"58: " + getCheckMessage(MSG_MISSING_TAG, "@incomplete"),
"62: " + getCheckMessage(MSG_WRITE_TAG, "@incomplete", "// violation"),
"62: " + getCheckMessage(MSG_WRITE_TAG, "@incomplete",
"Failed to recognize 'record' introduced in Java 14."),
};
verifyWithInlineConfigParser(
getNonCompilablePath("InputWriteTagRecordsAndCompactCtors.java"), expected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
//non-compiled with javac: Compilable with Java14
package com.puppycrawl.tools.checkstyle.checks.javadoc.writetag;

// violation below , 'Type Javadoc comment is missing @incomplete tag'
public class InputWriteTagRecordsAndCompactCtors { // violation

public class InputWriteTagRecordsAndCompactCtors { // violation 'missing @incomplete tag.'

// violation 2 lines below 'Type Javadoc tag @incomplete must match pattern '\\S''
/**
Expand All @@ -21,45 +21,45 @@ public class InputWriteTagRecordsAndCompactCtors { // violation
class TestClass {
}

// violation 2 lines below , 'Javadoc tag .*'
// violation 2 lines below 'Failed to recognize 'record' introduced in Java 14.'
/**
* @incomplete // violation
* @incomplete Failed to recognize 'record' introduced in Java 14.
*/
record MyRecord1() {

}

// violation below , 'Type Javadoc comment is missing @incomplete tag'
record MyRecord2(String myString) { // violation

// violation 2 lines below , 'Javadoc tag .*'
record MyRecord2(String myString) { // violation 'missing @incomplete tag.'

// violation 2 lines below 'Failed to recognize 'record' introduced in Java 14.'
/**
* @incomplete // violation
* @incomplete Failed to recognize 'record' introduced in Java 14.
*/
public MyRecord2 {
}
}

// violation below , 'Type Javadoc comment is missing @incomplete tag'
record MyRecord3(int x) { // violation

// violation 2 lines below , 'Javadoc tag .*'
record MyRecord3(int x) { // violation 'Type Javadoc comment is missing @incomplete tag.*'

// violation 2 lines below 'Failed to recognize 'record' introduced in Java 14.'
/**
* @incomplete // violation
* @incomplete Failed to recognize 'record' introduced in Java 14.
*/
MyRecord3() {
this(3);
}
}

// violation below , 'Type Javadoc comment is missing @incomplete tag'
record MyRecord4(int y) { // violation
// violation below , 'Type Javadoc comment is missing @incomplete tag'
private record MyRecord5(int z) { // violation

// violation 2 lines below , 'Javadoc tag .*'
record MyRecord4(int y) { // violation 'Type Javadoc comment is missing @incomplete tag.*'

private record MyRecord5(int z) { // violation 'missing @incomplete tag.'

// violation 2 lines below 'Failed to recognize 'record' introduced in Java 14.'
/**
* @incomplete // violation
* @incomplete Failed to recognize 'record' introduced in Java 14.
*/
public MyRecord5 {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

package com.puppycrawl.tools.checkstyle.checks.javadoc.writetag;
// violation 3 lines below , 'Javadoc tag .*'
// violation 3 lines below , 'param @author must match pattern '\\S'.*'
/**
* Testing tag writing
* @author Daniel Grenner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
*/

package com.puppycrawl.tools.checkstyle.checks.javadoc.writetag;
// violation 6 lines below , 'Javadoc tag .*'
// violation 6 lines below , 'Javadoc tag .*'
// violation 6 lines below , '@doubletag appeared at the same time.*'
// violation 6 lines below , '@doubletag appeared at the same time.*'
/**
* Testing tag writing
* @author Daniel Grenner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

package com.puppycrawl.tools.checkstyle.checks.javadoc.writetag;
// violation 7 lines below , 'Javadoc tag .*'

/**
* Testing tag writing
* @author Daniel Grenner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
WriteTag
tag = @incomplete
tagFormat = .*
tagSeverity = error
tagSeverity = (default)info
tokens = ANNOTATION_DEF, ENUM_DEF, ANNOTATION_FIELD_DEF, ENUM_CONSTANT_DEF
Expand All @@ -11,22 +11,26 @@
package com.puppycrawl.tools.checkstyle.checks.javadoc.writetag;

class InputWriteTagEnumsAndAnnotations {
// violation 2 lines below , '@incomplete should not be used in ANNOTATION.*'
/**
* @incomplete This enum needs more code... // violation
* @incomplete This enum needs more code...
*/
enum InputWriteTag {
// violation 2 lines below , '@incomplete should not be used in ENUM.*'
/**
* @incomplete This enum constant needs more code... // violation
* @incomplete This enum constant needs more code...
*/
FOO;
}

// violation 2 lines below , '@incomplete should not be used in ANNOTATION_FIELD.*'
/**
* @incomplete This annotation needs more code... // violation
* @incomplete This annotation needs more code...
*/
@interface InputWriteTag2a {
// violation 2 lines below , '@incomplete should not be used in ENUM_CONSTANT.*'
/**
* @incomplete This annotation field needs more code... // violation
* @incomplete This annotation field needs more code...
*/
int foo() default 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
*/

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

// violation 3 lines below 'tag @author must match pattern 'ABC'.'
/**
* Testing tag writing
* @author Daniel Grenner // violation
* @author Daniel Grenner
* @incomplete This class needs more code...
* @doubletag first text
* @doubletag second text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

package com.puppycrawl.tools.checkstyle.checks.javadoc.writetag;
// violation 4 lines below , 'Javadoc tag .*'
// violation 4 lines below , 'Must contain non-whitespace characters.*'
/**
* Testing tag writing
* @author Daniel Grenner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
class InputWriteTagMethod
{
// violation 2 lines below , 'Javadoc tag .*'
// violation 2 lines below , 'Add a constructor comment.*'
/**
* @todo Add a constructor comment
*/
Expand All @@ -31,7 +31,7 @@ public void method() // ok
{
}

// violation 2 lines below , 'Javadoc tag .*'
// violation 2 lines below , 'Add a comment.*'
/**
* @todo Add a comment
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

package com.puppycrawl.tools.checkstyle.checks.javadoc.writetag;
// violation 3 lines below , 'Javadoc tag .*'
// violation 3 lines below , 'Missing @author tag.*'
/**
* Testing tag writing
* @author Daniel Grenner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* @doubletag second text
* @emptytag
*/
class InputWriteTagMissingTag // violation
class InputWriteTagMissingTag // violation 'Type Javadoc comment is missing @missingtag tag.*'
{
/**
* @todo Add a constructor comment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

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

class InputWriteTagNoJavadoc // violation
class InputWriteTagNoJavadoc // violation 'Type Javadoc comment is missing null tag.'
{
public void method()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

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

// violation 3 lines below , 'Javadoc tag .*'
// violation 3 lines below , 'Must contain non-whitespace characters.*'
/**
* Testing tag writing
* @author Daniel Grenner
Expand Down

0 comments on commit 72f1822

Please sign in to comment.