Skip to content

Commit

Permalink
Issue #13345: Enable example tests for JavadocVariableCheckExamplesTest
Browse files Browse the repository at this point in the history
  • Loading branch information
prathm3 authored and romani committed May 9, 2024
1 parent b7d694c commit 14c818e
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 139 deletions.
Expand Up @@ -19,12 +19,12 @@

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;

@Disabled("until https://github.com/checkstyle/checkstyle/issues/13345")
public class JavadocVariableCheckExamplesTest extends AbstractExamplesModuleTestSupport {
@Override
protected String getPackageLocation() {
Expand All @@ -34,36 +34,42 @@ protected String getPackageLocation() {
@Test
public void testExample1() throws Exception {
final String[] expected = {

"12:3: " + getCheckMessage(MSG_JAVADOC_MISSING),
"18:3: " + getCheckMessage(MSG_JAVADOC_MISSING),
"19:3: " + getCheckMessage(MSG_JAVADOC_MISSING),
"20:15: " + getCheckMessage(MSG_JAVADOC_MISSING),
};

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

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

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

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

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

"15:3: " + getCheckMessage(MSG_JAVADOC_MISSING),
"23:15: " + getCheckMessage(MSG_JAVADOC_MISSING),
};

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

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

"14:3: " + getCheckMessage(MSG_JAVADOC_MISSING),
"20:3: " + getCheckMessage(MSG_JAVADOC_MISSING),
"21:3: " + getCheckMessage(MSG_JAVADOC_MISSING),
"22:15: " + getCheckMessage(MSG_JAVADOC_MISSING),
};

verifyWithInlineConfigParser(getPath("Example4.txt"), expected);
verifyWithInlineConfigParser(getPath("Example4.java"), expected);
}
}
@@ -0,0 +1,23 @@
/*xml
<module name="Checker">
<module name="TreeWalker">
<module name="JavadocVariable"/>
</module>
</module>
*/
package com.puppycrawl.tools.checkstyle.checks.javadoc.javadocvariable;

// xdoc section -- start
public class Example1 {
private int a; // violation

/**
* Some description here
*/
private int b;
protected int c; // violation
public int d; // violation
/*package*/ int e; // violation

}
// xdoc section -- end

This file was deleted.

@@ -0,0 +1,24 @@
/*xml
<module name="Checker">
<module name="TreeWalker">
<module name="JavadocVariable">
<property name="scope" value="public"/>
</module>
</module>
</module>
*/
package com.puppycrawl.tools.checkstyle.checks.javadoc.javadocvariable;

// xdoc section -- start
public class Example2 {
private int a;

/**
* Some description here
*/
private int b;
protected int c;
public int d; // violation
/*package*/ int e;
}
// xdoc section -- end

This file was deleted.

Expand Up @@ -8,17 +8,18 @@
</module>
</module>
*/
package com.puppycrawl.tools.checkstyle.checks.javadoc.javadocvariable;

// xdoc section -- start
public class Test {
private int a; // violation, missing javadoc for private member
public class Example3 {
private int a; // violation

/**
* Some description here
*/
private int b; // OK
protected int c; // OK
public int d; // OK
/*package*/ int e; // violation, missing javadoc for package member
/**
* Some description here
*/
private int b;
protected int c;
public int d;
/*package*/ int e; // violation
}
// xdoc section -- end
@@ -0,0 +1,24 @@
/*xml
<module name="Checker">
<module name="TreeWalker">
<module name="JavadocVariable">
<property name="ignoreNamePattern" value="log|logger"/>
</module>
</module>
</module>
*/
package com.puppycrawl.tools.checkstyle.checks.javadoc.javadocvariable;

// xdoc section -- start
public class Example4 {
private int a; // violation

/**
* Some description here
*/
private int b;
protected int c; // violation
public int d; // violation
/*package*/ int e; // violation
}
// xdoc section -- end

This file was deleted.

83 changes: 41 additions & 42 deletions src/xdocs/checks/javadoc/javadocvariable.xml
Expand Up @@ -81,16 +81,17 @@
there is no javadoc for any scope member.
</p>
<source>
public class Test {
private int a; // violation, missing javadoc for private member

/**
* Some description here
*/
private int b; // OK
protected int c; // violation, missing javadoc for protected member
public int d; // violation, missing javadoc for public member
/*package*/ int e; // violation, missing javadoc for package member
public class Example1 {
private int a; // violation

/**
* Some description here
*/
private int b;
protected int c; // violation
public int d; // violation
/*package*/ int e; // violation

}
</source>

Expand All @@ -113,16 +114,16 @@ public int d; // violation, missing javadoc for public member
is no javadoc for <code>public</code> member.
</p>
<source>
public class Test {
private int a; // OK

/**
* Some description here
*/
private int b; // OK
protected int c; // OK
public int d; // violation, missing javadoc for public member
/*package*/ int e; // OK
public class Example2 {
private int a;

/**
* Some description here
*/
private int b;
protected int c;
public int d; // violation
/*package*/ int e;
}
</source>

Expand All @@ -147,16 +148,16 @@ public int d; // violation, missing javadoc for public member
ignores <code>protected</code> member.
</p>
<source>
public class Test {
private int a; // violation, missing javadoc for private member

/**
* Some description here
*/
private int b; // OK
protected int c; // OK
public int d; // OK
/*package*/ int e; // violation, missing javadoc for package member
public class Example3 {
private int a; // violation

/**
* Some description here
*/
private int b;
protected int c;
public int d;
/*package*/ int e; // violation
}
</source>
<p id="Example4-config">
Expand All @@ -179,18 +180,16 @@ public int d; // OK
name <code>log</code> or <code>logger</code>.
</p>
<source>
public class Test {
private int a; // violation, missing javadoc for private member

/**
* Some description here
*/
private int b; // OK
protected int c; // violation, missing javadoc for protected member
public int d; // violation, missing javadoc for public member
/*package*/ int e; // violation, missing javadoc for package member
private int log; // OK
private int logger; // OK
public class Example4 {
private int a; // violation

/**
* Some description here
*/
private int b;
protected int c; // violation
public int d; // violation
/*package*/ int e; // violation
}
</source>
</subsection>
Expand Down

0 comments on commit 14c818e

Please sign in to comment.