Skip to content

Commit e7b7312

Browse files
committedNov 30, 2018
#848 dont require javadoc for methods in tests
1 parent b70f8e9 commit e7b7312

File tree

5 files changed

+45
-5
lines changed

5 files changed

+45
-5
lines changed
 

‎qulice-checkstyle/src/main/resources/com/qulice/checkstyle/checks.xml

+5-3
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,11 @@
169169
<property name="fileExtensions" value="java"/>
170170
</module>
171171

172-
<!--
173-
Enable suppressions
174-
-->
172+
<module name="SuppressionFilter">
173+
<property name="file" value="${project.basedir}/src/main/resources/com/qulice/checkstyle/suppressions.xml"/>
174+
<property name="optional" value="false"/>
175+
</module>
176+
175177
<module name="TreeWalker">
176178
<property name="cacheFile" value="${cache.file}" />
177179

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE suppressions PUBLIC "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN" "https://checkstyle.org/dtds/suppressions_1_2.dtd">
3+
4+
<suppressions>
5+
<suppress checks="JavadocMethod" files=".+(Test|ITCase|IT).java" />
6+
</suppressions>

‎qulice-checkstyle/src/test/java/com/qulice/checkstyle/CheckstyleValidatorTest.java

+15-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@
5353
* exclude `TooManyMethods`. Good candidates for moving out of this class
5454
* are all that use `validateCheckstyle` method.
5555
*/
56-
@SuppressWarnings({ "PMD.TooManyMethods", "PMD.AvoidDuplicateLiterals" })
56+
@SuppressWarnings(
57+
{
58+
"PMD.TooManyMethods", "PMD.AvoidDuplicateLiterals", "PMD.GodClass"
59+
}
60+
)
5761
public final class CheckstyleValidatorTest {
5862

5963
/**
@@ -167,6 +171,16 @@ public void reportsErrorWhenIndentationIsIncorrect() throws Exception {
167171
);
168172
}
169173

174+
/**
175+
* CheckstyleValidator does not report an error when there is no JavaDoc
176+
* on method in JUnit tests.
177+
* @throws Exception when error.
178+
*/
179+
@Test
180+
public void doesNotReportErrorWhenMissingJavadocInTests() throws Exception {
181+
this.runValidation("MissingJavadocTest.java", true);
182+
}
183+
170184
/**
171185
* CheckstyleValidator reports an error when comment or Javadoc has too
172186
* long line.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Hello.
3+
*/
4+
package foo;
5+
6+
import org.junit.Test;
7+
8+
/**
9+
* Simple.
10+
* @since 1.0
11+
*/
12+
public class MissingJavadocTest {
13+
14+
@Test
15+
public void testSomething() {
16+
return "something";
17+
}
18+
}

‎qulice-maven-plugin/src/it/checkstyle-violations/verify.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ assert log.text.contains('Violations.java[33]: ArrayList should be initialized w
4747
assert log.text.contains('Violations.java[34]: ArrayList should be initialized with a size parameter')
4848
assert log.text.findAll('Pdd.java.*: .todo tag has wrong format').empty
4949
assert !log.text.contains('Got an exception - java.lang.NullPointerException')
50-
//assert !log.text.contains('SomeTest.java[5]: This method must be static, because it does not refer to "this"')
50+
assert log.text.findAll('SomeTest.java .+ (JavadocMethodCheck)').isEmpty()
5151
assert !log.text.contains('IndentationChecks.java[19]: method call rparen at indentation level 12')

0 commit comments

Comments
 (0)
Please sign in to comment.