From fd3a0027d56c993b3e39bfc04925afd0aa6d7fc6 Mon Sep 17 00:00:00 2001
From: Amit Kumar Deohoria
Date: Thu, 21 Nov 2024 23:30:46 +0530
Subject: [PATCH] Issue #13345: Enable examples tests for
JavadocTagContinuationIndentationCheck
---
...tinuationIndentationCheckExamplesTest.java | 22 +++---
.../Example1.java | 33 +++++++++
.../Example1.txt | 18 -----
.../Example2.java | 35 ++++++++++
.../Example2.txt | 20 ------
.../Example3.java | 35 ++++++++++
.../Example3.txt | 18 -----
.../javadoctagcontinuationindentation.xml | 70 +++++++++++++++----
...doctagcontinuationindentation.xml.template | 12 ++--
9 files changed, 177 insertions(+), 86 deletions(-)
create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example1.java
delete mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example1.txt
create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example2.java
delete mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example2.txt
create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example3.java
delete mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example3.txt
diff --git a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheckExamplesTest.java b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheckExamplesTest.java
index c937afbee0e..800d6d688e5 100644
--- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheckExamplesTest.java
+++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheckExamplesTest.java
@@ -19,12 +19,14 @@
package com.puppycrawl.tools.checkstyle.checks.javadoc;
-import org.junit.jupiter.api.Disabled;
+import static com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck.MSG_KEY_UNCLOSED_HTML_TAG;
+import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTagContinuationIndentationCheck.MSG_KEY;
+
import org.junit.jupiter.api.Test;
import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
+import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
-@Disabled("until https://github.com/checkstyle/checkstyle/issues/13345")
public class JavadocTagContinuationIndentationCheckExamplesTest
extends AbstractExamplesModuleTestSupport {
@Override
@@ -35,27 +37,25 @@ protected String getPackageLocation() {
@Test
public void testExample1() throws Exception {
final String[] expected = {
-
+ "27: " + getCheckMessage(MSG_KEY, 4),
};
- verifyWithInlineConfigParser(getPath("Example1.txt"), expected);
+ verifyWithInlineConfigParser(getPath("Example1.java"), expected);
}
@Test
public void testExample2() throws Exception {
- final String[] expected = {
-
- };
-
- verifyWithInlineConfigParser(getPath("Example2.txt"), expected);
+ final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
+ verifyWithInlineConfigParser(getPath("Example2.java"), expected);
}
@Test
public void testExample3() throws Exception {
final String[] expected = {
-
+ "14: " + getCheckMessage(MSG_KEY_UNCLOSED_HTML_TAG, "p"),
+ "29: " + getCheckMessage(MSG_KEY, 4),
};
- verifyWithInlineConfigParser(getPath("Example3.txt"), expected);
+ verifyWithInlineConfigParser(getPath("Example3.java"), expected);
}
}
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example1.java b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example1.java
new file mode 100644
index 00000000000..31d6182e4a0
--- /dev/null
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example1.java
@@ -0,0 +1,33 @@
+/*xml
+
+
+
+
+
+*/
+package com.puppycrawl.tools.checkstyle.checks.javadoc.javadoctagcontinuationindentation;
+
+// xdoc section -- start
+/**
+ * 'p' tag is unclosed
+ *
'p' tag is closed
+ */
+class Example1 {
+
+ /**
+ * @tag comment
+ * Indentation spacing is 4
+ */
+ public void testMethod1(String input) {
+ // OK, Default expected Indentation is 4
+ }
+
+ /**
+ * @tag comment
+ * Indentation spacing is 2
+ */
+ public void testMethod2(String input) {
+ // violation 3 lines above 'Line continuation have incorrect indentation level'
+ }
+}
+// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example1.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example1.txt
deleted file mode 100644
index 6aea1397a7f..00000000000
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example1.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-/*xml
-
-
-
-
-
-*/
-
-// xdoc section -- start
-/**
- * @tag comment
- * Indentation spacing is 1. Line with violation
- * Indentation spacing is 2. Line with violation
- * Indentation spacing is 4. OK
- */
-public class Test {
-}
-// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example2.java b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example2.java
new file mode 100644
index 00000000000..5c303960888
--- /dev/null
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example2.java
@@ -0,0 +1,35 @@
+/*xml
+
+
+
+
+
+
+
+*/
+package com.puppycrawl.tools.checkstyle.checks.javadoc.javadoctagcontinuationindentation;
+
+// xdoc section -- start
+/**
+ * 'p' tag is unclosed
+ *
'p' tag is closed
+ */
+class Example2 {
+
+ /**
+ * @tag comment
+ * Indentation spacing is 4
+ */
+ public void testMethod1(String input) {
+ // OK, Indentation above 1 is fine as offset value is 2
+ }
+
+ /**
+ * @tag comment
+ * Indentation spacing is 2
+ */
+ public void testMethod2(String input) {
+ // OK, Indentation above 1 is fine as offset value is 2
+ }
+}
+// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example2.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example2.txt
deleted file mode 100644
index b2f3f854cc5..00000000000
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example2.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-/*xml
-
-
-
-
-
-
-
-*/
-
-// xdoc section -- start
-/**
- * @tag comment
- * Indentation spacing is 0. Line with violation
- * Indentation spacing is 2. OK
- * Indentation spacing is 1. Line with violation
- */
-public class Test {
-}
-// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example3.java b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example3.java
new file mode 100644
index 00000000000..8756cc1b99d
--- /dev/null
+++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example3.java
@@ -0,0 +1,35 @@
+/*xml
+
+
+
+
+
+
+
+*/
+package com.puppycrawl.tools.checkstyle.checks.javadoc.javadoctagcontinuationindentation;
+
+// xdoc section -- start
+/**
+ * 'p' tag is unclosed
+ *
'p' tag is closed
+ */
+class Example3 {
+ // violation 4 lines above 'Unclosed HTML tag found: p'
+ /**
+ * @tag comment
+ * Indentation spacing is 4
+ */
+ public void testMethod1(String input) {
+ // OK, Default expected Indentation is 4
+ }
+
+ /**
+ * @tag comment
+ * Indentation spacing is 1
+ */
+ public void testMethod2(String input) {
+ // violation 3 lines above 'Line continuation have incorrect indentation level'
+ }
+}
+// xdoc section -- end
diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example3.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example3.txt
deleted file mode 100644
index 6076c760d1a..00000000000
--- a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example3.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-/*xml
-
-
-
-
-
-
-
-*/
-
-// xdoc section -- start
-/**
- * 'p' tag is unclosed. Line with violation, this html tag needs closing tag.
- *
'p' tag is closed
. OK
- */
-public class Test {
-}
-// xdoc section -- end
diff --git a/src/xdocs/checks/javadoc/javadoctagcontinuationindentation.xml b/src/xdocs/checks/javadoc/javadoctagcontinuationindentation.xml
index cdc018a86dd..13d4d68f44c 100644
--- a/src/xdocs/checks/javadoc/javadoctagcontinuationindentation.xml
+++ b/src/xdocs/checks/javadoc/javadoctagcontinuationindentation.xml
@@ -64,12 +64,26 @@
/**
- * @tag comment
- * Indentation spacing is 1. Line with violation
- * Indentation spacing is 2. Line with violation
- * Indentation spacing is 4. OK
+ * <p> 'p' tag is unclosed
+ * <p> 'p' tag is closed</p>
*/
-public class Test {
+class Example1 {
+
+ /**
+ * @tag comment
+ * Indentation spacing is 4
+ */
+ public void testMethod1(String input) {
+ // OK, Default expected Indentation is 4
+ }
+
+ /**
+ * @tag comment
+ * Indentation spacing is 2
+ */
+ public void testMethod2(String input) {
+ // violation 3 lines above 'Line continuation have incorrect indentation level'
+ }
}
@@ -89,12 +103,26 @@ public class Test {
/**
- * @tag comment
- * Indentation spacing is 0. Line with violation
- * Indentation spacing is 2. OK
- * Indentation spacing is 1. Line with violation
+ * <p> 'p' tag is unclosed
+ * <p> 'p' tag is closed</p>
*/
-public class Test {
+class Example2 {
+
+ /**
+ * @tag comment
+ * Indentation spacing is 4
+ */
+ public void testMethod1(String input) {
+ // OK, Indentation above 1 is fine as offset value is 2
+ }
+
+ /**
+ * @tag comment
+ * Indentation spacing is 2
+ */
+ public void testMethod2(String input) {
+ // OK, Indentation above 1 is fine as offset value is 2
+ }
}
@@ -114,10 +142,26 @@ public class Test {
/**
- * <p> 'p' tag is unclosed. Line with violation, this html tag needs closing tag.
- * <p> 'p' tag is closed</p>. OK
+ * <p> 'p' tag is unclosed
+ * <p> 'p' tag is closed</p>
*/
-public class Test {
+class Example3 {
+ // violation 4 lines above 'Unclosed HTML tag found: p'
+ /**
+ * @tag comment
+ * Indentation spacing is 4
+ */
+ public void testMethod1(String input) {
+ // OK, Default expected Indentation is 4
+ }
+
+ /**
+ * @tag comment
+ * Indentation spacing is 1
+ */
+ public void testMethod2(String input) {
+ // violation 3 lines above 'Line continuation have incorrect indentation level'
+ }
}
diff --git a/src/xdocs/checks/javadoc/javadoctagcontinuationindentation.xml.template b/src/xdocs/checks/javadoc/javadoctagcontinuationindentation.xml.template
index 4130b03f7df..f9d3e1c3727 100644
--- a/src/xdocs/checks/javadoc/javadoctagcontinuationindentation.xml.template
+++ b/src/xdocs/checks/javadoc/javadoctagcontinuationindentation.xml.template
@@ -34,7 +34,7 @@
+ value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example1.java"/>
@@ -42,7 +42,7 @@
+ value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example1.java"/>
@@ -50,7 +50,7 @@
+ value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example2.java"/>
@@ -58,7 +58,7 @@
+ value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example2.java"/>
@@ -66,7 +66,7 @@
+ value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example3.java"/>
@@ -74,7 +74,7 @@
+ value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example3.java"/>