Add: Suppressions config for tests

This commit is contained in:
Lars Simon Winzer
2026-03-13 22:34:41 +01:00
parent e797470ca3
commit d311553de7
3 changed files with 35 additions and 2 deletions
+4
View File
@@ -46,6 +46,10 @@ test {
checkstyle { checkstyle {
toolVersion = '10.21.0' toolVersion = '10.21.0'
configFile = file('config/checkstyle/checkstyle.xml')
configProperties = [
'suppressionFile': file('config/checkstyle/suppressions.xml').absolutePath
]
} }
tasks.named('jar', Jar) { tasks.named('jar', Jar) {
+7 -2
View File
@@ -12,6 +12,10 @@
<!-- https://checkstyle.sourceforge.io/config.html#Properties_1 --> <!-- https://checkstyle.sourceforge.io/config.html#Properties_1 -->
<property name="fileExtensions" value="java"/> <property name="fileExtensions" value="java"/>
<module name="SuppressionFilter">
<property name="file" value="${suppressionFile}"/>
</module>
<!-- Only allow spaces --> <!-- Only allow spaces -->
<!-- https://checkstyle.sourceforge.io/checks/whitespace/filetabcharacter.html --> <!-- https://checkstyle.sourceforge.io/checks/whitespace/filetabcharacter.html -->
<module name="FileTabCharacter"/> <module name="FileTabCharacter"/>
@@ -141,9 +145,10 @@
<!-- Disallow System.out.println --> <!-- Disallow System.out.println -->
<!-- https://checkstyle.sourceforge.io/checks/regexp/regexp.html --> <!-- https://checkstyle.sourceforge.io/checks/regexp/regexp.html -->
<module name="Regexp"> <module name="Regexp">
<property name="id" value="SystemOutErr"/>
<property name="format" value="System\.(out|err)\.print"/> <property name="format" value="System\.(out|err)\.print"/>
<property name="illegalPattern" value="true"/> <property name="illegalPattern" value="true"/>
<property name="message" value="No `System.out.print(err)` in production code — use a logger."/> <property name="message" value="No `System.out.print(err)` allowed — use a logger."/>
</module> </module>
<!-- Disallow whitespace before semicolon or bracket --> <!-- Disallow whitespace before semicolon or bracket -->
@@ -159,7 +164,7 @@
<module name="Regexp"> <module name="Regexp">
<property name="format" value=" +$"/> <property name="format" value=" +$"/>
<property name="illegalPattern" value="true"/> <property name="illegalPattern" value="true"/>
<property name="message" value="Kein trailing Whitespace."/> <property name="message" value="No trailing whitespace."/>
</module> </module>
</module> </module>
</module> </module>
+24
View File
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<!-- Allow literal, for example assertEquals(42, life.answer()) -->
<suppress checks="MagicNumber" files=".*Test\.java"/>
<!-- Allow longer method names as the are usually descriptive of the test -->
<suppress checks="MethodLength" files=".*Test\.java"/>
<!-- Allow methods with more parameters -->
<suppress checks="ParameterNumber" files=".*Test\.java"/>
<!-- Allow for System.out.println in tests -->
<suppress id="SystemOutErr" files=".*Test\.java"/>
<!-- Allow wildcard imports (import x.*) -->
<suppress checks="AvoidStarImport" files=".*Test\.java"/>
<!-- Allow for compacter line seperators -->
<suppress checks="EmptyLineSeparator" files=".*Test\.java"/>
</suppressions>