Repository: checkstyle/checkstyle

Problem statement:
JavadocTagContinuationIndentation does not check text inside HTML elements
From https://github.com/checkstyle/checkstyle/pull/8177#discussion_r579386002

Check documentation: https://checkstyle.org/config_javadoc.html#JavadocTagContinuationIndentation

```cmd
D:\checkstyletest>type config.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
          "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
          "https://checkstyle.org/dtds/configuration_1_3.dtd">

<module name="Checker">
    <property name="severity" value="error"/>
    <module name="TreeWalker">
                  <module name="JavadocTagContinuationIndentation"/>
    </module>
</module>

D:\checkstyletest>type test\MyClass.java
class MyClass {

    /**
     * Javadoc.
     *
     * @param x This is the start of a param tag.
     *     Continuing lines must have indentation. // ok
     * Lines without indentation are violations. // violation
     * <p>HTML tags are also affected by this rule.</p> // not a violation yet, will be fixed in #8177
     * And subsequent text is also checked. // violation
     *     <p>
     * However, text nested inside HTML elements are unaffected. // no violation
     *     </p>
     */
    void foo(int x) {
        // do stuff
    }

}
D:\checkstyletest>set RUN_LOCALE="-Duser.language=en -Duser.country=US"

D:\checkstyletest>java -jar "-Duser.language=en -Duser.country=US" checkstyle-8.40-all.jar -c config.xml test\MyClass.java
Starting audit...
[ERROR] D:\checkstyletest\test\MyClass.java:8: Line continuation have incorrect indentation level, expected level should be 4. [JavadocTagContinuationIndentation]
[ERROR] D:\checkstyletest\test\MyClass.java:10: Line continuation have incorrect indentation level, expected level should be 4. [JavadocTagContinuationIndentation]
Audit done.
Checkstyle ends with 2 errors.
```

---

The line `However, text nested inside HTML elements are unaffected.` does not raise any violation, despite having no indentation with respect to the `@param` tag. In general, when HTML elements are involved the text between the start and end tags is not checked.

This behavior may be unintuitive as the check documentation does not have any examples on whether or not this is considered a violation.
- ~~If this is intended behavior, then the documentation should be updated to include a similar example so that future users will not be confused by this case.~~ see https://github.com/checkstyle/checkstyle/issues/9315#issuecomment-808765706
- Otherwise, if this is considered a bug then please see https://github.com/checkstyle/checkstyle/pull/8177#discussion_r579386002 for details on how it may be fixed.


Hints:
@romani I want to work on this.

> if this is considered a bug

is this a bug? or do I need to update the documentation?
it is bug, 
nor now, I do not think we need to update docuemntation 

Patch:
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheck.java
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheck.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheck.java
@@ -225,6 +225,10 @@ private static List<DetailNode> getAllNewlineNodes(DetailNode descriptionNode) {
         final List<DetailNode> textNodes = new ArrayList<>();
         DetailNode node = JavadocUtil.getFirstChild(descriptionNode);
         while (JavadocUtil.getNextSibling(node) != null) {
+            if (node.getType() == JavadocTokenTypes.HTML_ELEMENT) {
+                final DetailNode descriptionNodeChild = JavadocUtil.getFirstChild(node);
+                textNodes.addAll(getAllNewlineNodes(descriptionNodeChild));
+            }
             if (node.getType() == JavadocTokenTypes.LEADING_ASTERISK) {
                 textNodes.add(node);
             }


Test patch:
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheckTest.java
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheckTest.java
@@ -126,6 +126,19 @@ public void testBlockTag() throws Exception {
             "86: " + getCheckMessage(MSG_KEY, 4),
             "87: " + getCheckMessage(MSG_KEY, 4),
             "88: " + getCheckMessage(MSG_KEY, 4),
+            "89: " + getCheckMessage(MSG_KEY, 4),
+            "90: " + getCheckMessage(MSG_KEY, 4),
+            "91: " + getCheckMessage(MSG_KEY, 4),
+            "92: " + getCheckMessage(MSG_KEY, 4),
+            "93: " + getCheckMessage(MSG_KEY, 4),
+            "94: " + getCheckMessage(MSG_KEY, 4),
+            "95: " + getCheckMessage(MSG_KEY, 4),
+            "96: " + getCheckMessage(MSG_KEY, 4),
+            "97: " + getCheckMessage(MSG_KEY, 4),
+            "98: " + getCheckMessage(MSG_KEY, 4),
+            "99: " + getCheckMessage(MSG_KEY, 4),
+            "104: " + getCheckMessage(MSG_KEY, 4),
+            "105: " + getCheckMessage(MSG_KEY, 4),
         };
         verify(checkConfig, getPath("InputJavadocTagContinuationIndentationBlockTag.java"),
                 expected);
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/InputJavadocTagContinuationIndentationBlockTag.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/InputJavadocTagContinuationIndentationBlockTag.java
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/InputJavadocTagContinuationIndentationBlockTag.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/InputJavadocTagContinuationIndentationBlockTag.java
@@ -86,18 +86,24 @@ public boolean isMultipleLines2() {
      * if the commandline is initially null, the function is a noop
      * otherwise the function append to the commandline arguments concerning
      * <ul> // violation, not correctly indented
-     * <li> // ok, inside a HTML element
-     * cvs package // ok, inside a HTML element
-     * </li> // ok, inside a HTML element
-     * <li> // ok, inside a HTML element
-     * compression // ok, inside a HTML element
-     * </li> // ok, inside a HTML element
-     * <li> // ok, inside a HTML element
-     * quiet or reallyquiet // ok, inside a HTML element
-     * </li> // ok, inside a HTML element
-     * <li>cvsroot</li> // ok, inside a HTML element
-     * <li>noexec</li> // ok, inside a HTML element
-     * </ul> // ok, inside a HTML element
+     * <li> // violation, not correctly indented
+     * cvs package // violation, not correctly indented
+     * </li> // violation, not correctly indented
+     * <li> // violation, not correctly indented
+     * compression // violation, not correctly indented
+     * </li> // violation, not correctly indented
+     * <li> // violation, not correctly indented
+     * quiet or reallyquiet // violation, not correctly indented
+     * </li> // violation, not correctly indented
+     * <li>cvsroot</li> // violation, not correctly indented
+     * <li>noexec</li> // violation, not correctly indented
+     *     <li>
+     *     another item // ok
+     *     </li>
+     *     <li> yet another item </li> // ok
+     * </ul> // violation, not correctly indented
+     * some text <i>word</i> more text. // violation
+     *     some text <i>word</i> more text. // ok
      */
     public String regressionNestedHtml(CharSequence c) {
         return "";