Skip to content

Commit

Permalink
Issue checkstyle#13345: Enable examples tests for JavadocTagContinuat…
Browse files Browse the repository at this point in the history
…ionIndentationCheck
  • Loading branch information
AmitKumarDeoghoria authored and romani committed Nov 22, 2024
1 parent 95a2f94 commit fd3a002
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*xml
<module name="Checker">
<module name="TreeWalker">
<module name="JavadocTagContinuationIndentation"/>
</module>
</module>
*/
package com.puppycrawl.tools.checkstyle.checks.javadoc.javadoctagcontinuationindentation;

// xdoc section -- start
/**
* <p> 'p' tag is unclosed
* <p> 'p' tag is closed</p>
*/
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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*xml
<module name="Checker">
<module name="TreeWalker">
<module name="JavadocTagContinuationIndentation">
<property name="offset" value="2"/>
</module>
</module>
</module>
*/
package com.puppycrawl.tools.checkstyle.checks.javadoc.javadoctagcontinuationindentation;

// xdoc section -- start
/**
* <p> 'p' tag is unclosed
* <p> 'p' tag is closed</p>
*/
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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*xml
<module name="Checker">
<module name="TreeWalker">
<module name="JavadocTagContinuationIndentation">
<property name="violateExecutionOnNonTightHtml" value="true"/>
</module>
</module>
</module>
*/
package com.puppycrawl.tools.checkstyle.checks.javadoc.javadoctagcontinuationindentation;

// xdoc section -- start
/**
* <p> 'p' tag is unclosed
* <p> 'p' tag is closed</p>
*/
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

This file was deleted.

70 changes: 57 additions & 13 deletions src/xdocs/checks/javadoc/javadoctagcontinuationindentation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,26 @@
</p>
<source>
/**
* @tag comment
* Indentation spacing is 1. Line with violation
* Indentation spacing is 2. Line with violation
* Indentation spacing is 4. OK
* &lt;p&gt; 'p' tag is unclosed
* &lt;p&gt; 'p' tag is closed&lt;/p&gt;
*/
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'
}
}
</source>
<p id="Example2-config">
Expand All @@ -89,12 +103,26 @@ public class Test {
</p>
<source>
/**
* @tag comment
* Indentation spacing is 0. Line with violation
* Indentation spacing is 2. OK
* Indentation spacing is 1. Line with violation
* &lt;p&gt; 'p' tag is unclosed
* &lt;p&gt; 'p' tag is closed&lt;/p&gt;
*/
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
}
}
</source>
<p id="Example3-config">
Expand All @@ -114,10 +142,26 @@ public class Test {
</p>
<source>
/**
* &lt;p&gt; 'p' tag is unclosed. Line with violation, this html tag needs closing tag.
* &lt;p&gt; 'p' tag is closed&lt;/p&gt;. OK
* &lt;p&gt; 'p' tag is unclosed
* &lt;p&gt; 'p' tag is closed&lt;/p&gt;
*/
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'
}
}
</source>
</subsection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,47 +34,47 @@
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example1.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example1.java"/>
<param name="type" value="config"/>
</macro>
<p id="Example1-code">
Example:
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example1.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example1.java"/>
<param name="type" value="code"/>
</macro>
<p id="Example2-config">
To configure the check with two spaces indentation:
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example2.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example2.java"/>
<param name="type" value="config"/>
</macro>
<p id="Example2-code">
Example:
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example2.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example2.java"/>
<param name="type" value="code"/>
</macro>
<p id="Example3-config">
To configure the check to show violations for Tight-HTML Rules:
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example3.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example3.java"/>
<param name="type" value="config"/>
</macro>
<p id="Example3-code">
Example:
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example3.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctagcontinuationindentation/Example3.java"/>
<param name="type" value="code"/>
</macro>
</subsection>
Expand Down

0 comments on commit fd3a002

Please sign in to comment.