Skip to content

Commit 14f8749

Browse files
committed
Checkstyle: Remove exceptions for JUnit 4 annotations
Checkstyle contains exceptions to allow certain exceptions in coding style for JUnit 4 tests. For example, Checkstyle allows declaration of a public variable if it is preceded by a Rule tag so as to ensure correct variable assignment by JUnit 4. After migrating all tests to JUnit 5, we no longer need these exceptions for annotations specific to JUnit 4. Hence, we can remove these annotations to tighten our strictness on coding style. Hence, let's remove exceptions in checkstyle for JUnit 4 annotations. Notably, let's remove * Before/BeforeClass/After/AfterClass tags used to denote functions to run before/after a test * Rule/ClassRule tags used to denote rules (now extensions in JUnit 5)
1 parent 4efa033 commit 14f8749

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

config/checkstyle/checkstyle.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@
229229
<module name="VisibilityModifier">
230230
<property name="protectedAllowed" value="true"/>
231231
<property name="allowPublicFinalFields" value="true"/>
232-
<property name="ignoreAnnotationCanonicalNames" value="Rule, ClassRule, RegisterExtension, TempDir"/>
232+
<property name="ignoreAnnotationCanonicalNames" value="RegisterExtension, TempDir"/>
233233
</module>
234234

235235
<!--
@@ -391,7 +391,7 @@
391391
Single line of code methods are often due to refactor for readability.
392392
-->
393393
<property name="minLineCount" value="1"/>
394-
<property name="allowedAnnotations" value="Override, Test, Before, BeforeAll, BeforeClass, BeforeEach, After, AfterAll, AfterClass, AfterEach, Subscribe"/>
394+
<property name="allowedAnnotations" value="Override, Test, BeforeAll, BeforeEach, AfterAll, AfterEach, Subscribe"/>
395395
<property name="scope" value="public"/>
396396
<property name="allowUndeclaredRTE" value="true"/>
397397
<property name="allowThrowsTagsForSubclasses" value="true"/>
@@ -408,7 +408,7 @@
408408
We define methods that have more than 3 lines of code as non-trivial.
409409
-->
410410
<property name="minLineCount" value="3"/>
411-
<property name="allowedAnnotations" value="Override, Test, Before, BeforeAll, BeforeClass, BeforeEach, After, AfterAll, AfterClass, AfterEach, Subscribe"/>
411+
<property name="allowedAnnotations" value="Override, Test, BeforeAll, BeforeEach, AfterAll, AfterEach, Subscribe"/>
412412
<property name="scope" value="private"/>
413413
<property name="allowUndeclaredRTE" value="true"/>
414414
<property name="allowThrowsTagsForSubclasses" value="true"/>

0 commit comments

Comments
 (0)