Skip to content

Commit

Permalink
Issue checkstyle#13345: Enable examples tests for MissingjavadocTypeC…
Browse files Browse the repository at this point in the history
…heck
  • Loading branch information
AmitKumarDeoghoria authored and romani committed Dec 21, 2024
1 parent 608d4a5 commit 8e5396f
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@

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

import org.junit.jupiter.api.Disabled;
import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocVariableCheck.MSG_JAVADOC_MISSING;

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 MissingJavadocTypeCheckExamplesTest extends AbstractExamplesModuleTestSupport {
@Override
protected String getPackageLocation() {
Expand All @@ -33,46 +34,29 @@ protected String getPackageLocation() {

@Test
public void testExample1() throws Exception {
final String[] expected = {

};

verifyWithInlineConfigParser(getPath("Example1.txt"), expected);
final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
verifyWithInlineConfigParser(getPath("Example1.java"), expected);
}

@Test
public void testExample2() throws Exception {
final String[] expected = {

"13:1: " + getCheckMessage(MSG_JAVADOC_MISSING),
"16:3: " + getCheckMessage(MSG_JAVADOC_MISSING),
"17:3: " + getCheckMessage(MSG_JAVADOC_MISSING),
"18:3: " + getCheckMessage(MSG_JAVADOC_MISSING),
"19:3: " + getCheckMessage(MSG_JAVADOC_MISSING),
};

verifyWithInlineConfigParser(getPath("Example2.txt"), expected);
verifyWithInlineConfigParser(getPath("Example2.java"), expected);
}

@Test
public void testExample3() throws Exception {
final String[] expected = {

};

verifyWithInlineConfigParser(getPath("Example3.txt"), expected);
}

@Test
public void testExample4() throws Exception {
final String[] expected = {

};

verifyWithInlineConfigParser(getPath("Example4.txt"), expected);
}

@Test
public void testExample5() throws Exception {
final String[] expected = {

"18:3: " + getCheckMessage(MSG_JAVADOC_MISSING),
};

verifyWithInlineConfigParser(getPath("Example5.txt"), expected);
verifyWithInlineConfigParser(getPath("Example3.java"), expected);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*xml
<module name="Checker">
<module name="TreeWalker">
<module name="MissingJavadocType"/>
</module>
</module>
*/
package com.puppycrawl.tools.checkstyle.checks.javadoc.missingjavadoctype;

// xdoc section -- start
class Example1 {
/** Javadoc.*/
public class testClass0 {}
public class testClass1 {}
private class testClass2 {}
protected class testClass3 {}
class testClass4 {}
}
// xdoc section -- end

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*xml
<module name="Checker">
<module name="TreeWalker">
<module name="MissingJavadocType">
<property name="scope" value="private"/>
</module>
</module>
</module>
*/
package com.puppycrawl.tools.checkstyle.checks.javadoc.missingjavadoctype;

// xdoc section -- start
class Example2 { // violation, 'Missing a Javadoc comment'
/** Javadoc.*/
public class testClass0 {}
public class testClass1 {} // violation, 'Missing a Javadoc comment'
private class testClass2 {} // violation, 'Missing a Javadoc comment'
protected class testClass3 {} // violation, 'Missing a Javadoc comment'
class testClass4 {} // violation, 'Missing a Javadoc comment'
}
// xdoc section -- end

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*xml
<module name="Checker">
<module name="TreeWalker">
<module name="MissingJavadocType">
<property name="scope" value="private"/>
<property name="excludeScope" value="package"/>
</module>
</module>
</module>
*/
package com.puppycrawl.tools.checkstyle.checks.javadoc.missingjavadoctype;

// xdoc section -- start
class Example3 {
/** Javadoc.*/
public class testClass0 {}
public class testClass1 {}
private class testClass2 {} // violation, 'Missing a Javadoc comment'
protected class testClass3 {}
class testClass4 {}

}
// xdoc section -- end

This file was deleted.

47 changes: 30 additions & 17 deletions src/xdocs/checks/javadoc/missingjavadoctype.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,16 @@
&lt;/module&gt;
</source>

<p id="Example1-code">Example:</p>
<p id="Example1-code">Example1:</p>
<source>
public class PublicClass {} // violation
private class PublicClass {}
protected class PublicClass {}
class PackagePrivateClass {}
class Example1 {
/** Javadoc.*/
public class testClass0 {}
public class testClass1 {}
private class testClass2 {}
protected class testClass3 {}
class testClass4 {}
}
</source>

<p id="Example2-config">
Expand All @@ -118,12 +122,16 @@ class PackagePrivateClass {}
&lt;/module&gt;
</source>

<p id="Example2-code">Example:</p>
<p id="Example2-code">Example2:</p>
<source>
public class PublicClass {} // violation
private class PublicClass {} // violation
protected class PublicClass {} // violation
class PackagePrivateClass {} // violation
class Example2 { // violation, 'Missing a Javadoc comment'
/** Javadoc.*/
public class testClass0 {}
public class testClass1 {} // violation, 'Missing a Javadoc comment'
private class testClass2 {} // violation, 'Missing a Javadoc comment'
protected class testClass3 {} // violation, 'Missing a Javadoc comment'
class testClass4 {} // violation, 'Missing a Javadoc comment'
}
</source>

<p id="Example3-config">
Expand All @@ -140,12 +148,17 @@ class PackagePrivateClass {} // violation
&lt;/module&gt;
</source>

<p id="Example3-code">Example:</p>
<p id="Example3-code">Example3:</p>
<source>
public class PublicClass {}
private class PublicClass {} // violation
protected class PublicClass {}
class PackagePrivateClass {}
class Example3 {
/** Javadoc.*/
public class testClass0 {}
public class testClass1 {}
private class testClass2 {} // violation, 'Missing a Javadoc comment'
protected class testClass3 {}
class testClass4 {}

}
</source>

<p id="Example4-config">
Expand All @@ -161,7 +174,7 @@ class PackagePrivateClass {}
&lt;/module&gt;
&lt;/module&gt;
</source>
<p id="Example4-code">Example:</p>
<p id="Example4-code">Example4:</p>
<source>
@SpringBootApplication // no violations about missing comment on class
public class Application {}
Expand All @@ -184,7 +197,7 @@ class DatabaseConfiguration {}
&lt;/module&gt;
</source>
<p id="Example5-code">
Example:
Example5:
</p>
<source>
@Annotation // ok
Expand Down
22 changes: 11 additions & 11 deletions src/xdocs/checks/javadoc/missingjavadoctype.xml.template
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadoctype/Example1.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadoctype/Example1.java"/>
<param name="type" value="config"/>
</macro>

<p id="Example1-code">Example:</p>
<p id="Example1-code">Example1:</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadoctype/Example1.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadoctype/Example1.java"/>
<param name="type" value="code"/>
</macro>

Expand All @@ -50,14 +50,14 @@
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadoctype/Example2.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadoctype/Example2.java"/>
<param name="type" value="config"/>
</macro>

<p id="Example2-code">Example:</p>
<p id="Example2-code">Example2:</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadoctype/Example2.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadoctype/Example2.java"/>
<param name="type" value="code"/>
</macro>

Expand All @@ -66,14 +66,14 @@
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadoctype/Example3.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadoctype/Example3.java"/>
<param name="type" value="config"/>
</macro>

<p id="Example3-code">Example:</p>
<p id="Example3-code">Example3:</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadoctype/Example3.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadoctype/Example3.java"/>
<param name="type" value="code"/>
</macro>

Expand All @@ -86,7 +86,7 @@
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadoctype/Example4.txt"/>
<param name="type" value="config"/>
</macro>
<p id="Example4-code">Example:</p>
<p id="Example4-code">Example4:</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadoctype/Example4.txt"/>
Expand All @@ -103,7 +103,7 @@
<param name="type" value="config"/>
</macro>
<p id="Example5-code">
Example:
Example5:
</p>
<macro name="example">
<param name="path"
Expand Down

0 comments on commit 8e5396f

Please sign in to comment.