Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #13345: Enable example tests for JavadocVariableCheckExamplesTest #14860

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
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);
}
}
Original file line number Diff line number Diff line change
@@ -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.

Original file line number Diff line number Diff line change
@@ -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.

Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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