diff --git a/pom.xml b/pom.xml
index 59176000a42..ccf7fe96ab7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1607,8 +1607,6 @@
**/AllBlockCommentsTest.class
- **/NonEmptyAtclauseDescriptionCheckTest.class
-
**/WriteTagCheckTest.class
**/AbstractJavadocCheckTest.class
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/bdd/InlineConfigParser.java b/src/test/java/com/puppycrawl/tools/checkstyle/bdd/InlineConfigParser.java
index 567e3d706a4..fe535a26cdf 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/bdd/InlineConfigParser.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/bdd/InlineConfigParser.java
@@ -76,6 +76,14 @@ public final class InlineConfigParser {
private static final Pattern FILTERED_VIOLATION_BELOW_PATTERN = Pattern
.compile(".*//\\s*filtered violation below(?:\\W+'(.*)')?$");
+ /** A pattern to find the string: "// violation X lines above". */
+ private static final Pattern VIOLATION_SOME_LINES_ABOVE_PATTERN = Pattern
+ .compile(".*//\\s*violation (\\d+) lines above(?:\\W+'(.*)')?$");
+
+ /** A pattern to find the string: "// violation X lines below". */
+ private static final Pattern VIOLATION_SOME_LINES_BELOW_PATTERN = Pattern
+ .compile(".*//\\s*violation (\\d+) lines below(?:\\W+'(.*)')?$");
+
/** The String "(null)". */
private static final String NULL_STRING = "(null)";
@@ -285,6 +293,10 @@ private static void setViolations(TestInputConfiguration.Builder inputConfigBuil
MULTIPLE_VIOLATIONS_ABOVE_PATTERN.matcher(lines.get(lineNo));
final Matcher multipleViolationsBelowMatcher =
MULTIPLE_VIOLATIONS_BELOW_PATTERN.matcher(lines.get(lineNo));
+ final Matcher violationSomeLinesAboveMatcher =
+ VIOLATION_SOME_LINES_ABOVE_PATTERN.matcher(lines.get(lineNo));
+ final Matcher violationSomeLinesBelowMatcher =
+ VIOLATION_SOME_LINES_BELOW_PATTERN.matcher(lines.get(lineNo));
if (violationMatcher.matches()) {
inputConfigBuilder.addViolation(lineNo + 1, violationMatcher.group(1));
}
@@ -294,6 +306,16 @@ else if (violationAboveMatcher.matches()) {
else if (violationBelowMatcher.matches()) {
inputConfigBuilder.addViolation(lineNo + 2, violationBelowMatcher.group(1));
}
+ else if (violationSomeLinesAboveMatcher.matches()) {
+ final int linesAbove = Integer.parseInt(violationSomeLinesAboveMatcher.group(1)) - 1;
+ inputConfigBuilder.addViolation(lineNo - linesAbove,
+ violationSomeLinesAboveMatcher.group(2));
+ }
+ else if (violationSomeLinesBelowMatcher.matches()) {
+ final int linesBelow = Integer.parseInt(violationSomeLinesBelowMatcher.group(1)) + 1;
+ inputConfigBuilder.addViolation(lineNo + linesBelow,
+ violationSomeLinesBelowMatcher.group(2));
+ }
else if (multipleViolationsMatcher.matches()) {
Collections
.nCopies(Integer.parseInt(multipleViolationsMatcher.group(1)), lineNo + 1)
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheckTest.java
index 7f13505b475..45ed7a11632 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheckTest.java
@@ -25,7 +25,6 @@
import org.junit.jupiter.api.Test;
import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
-import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
public class NonEmptyAtclauseDescriptionCheckTest
@@ -55,38 +54,35 @@ public void testGetRequiredTokens() {
}
@Test
- public void testCheck()
- throws Exception {
- final DefaultConfiguration checkConfig =
- createModuleConfig(NonEmptyAtclauseDescriptionCheck.class);
+ public void testCheck() throws Exception {
final String[] expected = {
- // this is a case with description that is sequences of spaces
- "36: " + getCheckMessage(MSG_KEY),
// this is a case with description that is sequences of spaces
"37: " + getCheckMessage(MSG_KEY),
// this is a case with description that is sequences of spaces
"38: " + getCheckMessage(MSG_KEY),
// this is a case with description that is sequences of spaces
- "47: " + getCheckMessage(MSG_KEY),
+ "39: " + getCheckMessage(MSG_KEY),
+ // this is a case with description that is sequences of spaces
+ "50: " + getCheckMessage(MSG_KEY),
// this is a case with description that is sequences of spaces
- "48: " + getCheckMessage(MSG_KEY),
+ "51: " + getCheckMessage(MSG_KEY),
// this is a case with description that is sequences of spaces
- "49: " + getCheckMessage(MSG_KEY),
- "85: " + getCheckMessage(MSG_KEY),
- "86: " + getCheckMessage(MSG_KEY),
- "87: " + getCheckMessage(MSG_KEY),
- "88: " + getCheckMessage(MSG_KEY),
- "89: " + getCheckMessage(MSG_KEY),
- "90: " + getCheckMessage(MSG_KEY),
- "99: " + getCheckMessage(MSG_KEY),
- "100: " + getCheckMessage(MSG_KEY),
- "101: " + getCheckMessage(MSG_KEY),
- "102: " + getCheckMessage(MSG_KEY),
- "103: " + getCheckMessage(MSG_KEY),
- "130: " + getCheckMessage(MSG_KEY),
- "139: " + getCheckMessage(MSG_KEY),
+ "52: " + getCheckMessage(MSG_KEY),
+ "92: " + getCheckMessage(MSG_KEY),
+ "93: " + getCheckMessage(MSG_KEY),
+ "94: " + getCheckMessage(MSG_KEY),
+ "95: " + getCheckMessage(MSG_KEY),
+ "96: " + getCheckMessage(MSG_KEY),
+ "97: " + getCheckMessage(MSG_KEY),
+ "110: " + getCheckMessage(MSG_KEY),
+ "111: " + getCheckMessage(MSG_KEY),
+ "112: " + getCheckMessage(MSG_KEY),
+ "113: " + getCheckMessage(MSG_KEY),
+ "114: " + getCheckMessage(MSG_KEY),
+ "143: " + getCheckMessage(MSG_KEY),
+ "152: " + getCheckMessage(MSG_KEY),
};
- verify(checkConfig, getPath("InputNonEmptyAtclauseDescription.java"), expected);
+ verifyWithInlineConfigParser(getPath("InputNonEmptyAtclauseDescription.java"), expected);
}
}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/nonemptyatclausedescription/InputNonEmptyAtclauseDescription.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/nonemptyatclausedescription/InputNonEmptyAtclauseDescription.java
index 91db1618e48..fa3773f95b9 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/nonemptyatclausedescription/InputNonEmptyAtclauseDescription.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/nonemptyatclausedescription/InputNonEmptyAtclauseDescription.java
@@ -31,23 +31,27 @@ public InputNonEmptyAtclauseDescription(String a)
}
+ // violation 3 lines below
/**
* Some javadoc.
* @param a
* @param b
* @param c
- */
+ */ // violation 2 lines above
+ // violation 2 lines above
public InputNonEmptyAtclauseDescription(String a, int b, double c)
{
}
+ // violation 3 lines below
/**
*
* @param a
* @param e
* @deprecated
- */
+ */ // violation 2 lines above
+ // violation 2 lines above
public InputNonEmptyAtclauseDescription(String a, boolean e)
{
@@ -80,6 +84,9 @@ public int foo2(String a, int b, double c) throws Exception
return 1;
}
+ // violation 5 lines below
+ // violation 5 lines below
+ // violation 5 lines below
/**
*
* @param a
@@ -88,12 +95,16 @@ public int foo2(String a, int b, double c) throws Exception
* @deprecated
* @throws Exception
* @deprecated
- */ // violation above
+ */ // violation 3 lines above
+ // violation 3 lines above
+ // violation 3 lines above
public int foo3(String a, int b, double c) throws Exception
{
return 1;
}
+ // violation 4 lines below
+ // violation 4 lines below
/**
*
* @param a
@@ -101,7 +112,9 @@ public int foo3(String a, int b, double c) throws Exception
* @param c
* @deprecated
* @throws Exception
- */
+ */ // violation 3 lines above
+ // violation 3 lines above
+ // violation 3 lines above
public int foo4(String a, int b, double c) throws Exception
{
return 1;
@@ -128,7 +141,7 @@ public int foo5(String a, int b, double c) throws Exception
* @param c Some javadoc
* @return Some javadoc
* @exception Exception
- */
+ */ // violation above
public int foo6(String a, int b, double c) throws Exception
{
return 1;
@@ -137,7 +150,7 @@ public int foo6(String a, int b, double c) throws Exception
/**
* @param a xxx
* @return
- */ // ^ violation
+ */ // violation above
int foo(int a) {
return a;
}