Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">

<!--
Starter ruleset for moza-profiel-service. Deliberately small: only the rules the
team already follows plus the ones that have come up in review. Severity is "warning"
so this stays informational until the team decides to gate (raise to "error" + bind
the check goal to verify in pom.xml). Grow the ruleset by adding modules below.
-->
<module name="Checker">
<property name="severity" value="error"/>
<property name="charset" value="UTF-8"/>
<property name="fileExtensions" value="java"/>

<!-- Max line length (matches the project's existing ~120-col convention). -->
<module name="LineLength">
<property name="max" value="120"/>
<property name="ignorePattern" value="^package.*|^import.*|^\s*\*.*https?://"/>
</module>

<!-- No more than one consecutive blank line. -->
<module name="RegexpMultiline">
<property name="format" value="\r?\n[ \t]*\r?\n[ \t]*\r?\n"/>
<property name="message" value="Meerdere opeenvolgende lege regels"/>
</module>

<!-- Optional suppressions; absent file is fine. -->
<module name="SuppressionFilter">
<property name="file" value="config/checkstyle/suppressions.xml"/>
<property name="optional" value="true"/>
</module>

<module name="TreeWalker">
<!-- Imports -->
<module name="AvoidStarImport"/>
<module name="UnusedImports">
<property name="processJavadoc" value="true"/>
</module>
<module name="RedundantImport"/>
<module name="CustomImportOrder">
<property name="customImportOrderRules"
value="THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE###STATIC"/>
<property name="standardPackageRegExp" value="^(java|javax)\."/>
<property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="separateLineBetweenGroups" value="true"/>
</module>

<!-- Complexity (suppressed for test sources via suppressions.xml) -->
<module name="CyclomaticComplexity">
<property name="max" value="15"/>
</module>
<module name="NPathComplexity"/>
<module name="BooleanExpressionComplexity"/>

<!-- Whitespace / statements -->
<module name="WhitespaceAround">
<!-- Don't flag idiomatic empty bodies like `record X(...) {}`. -->
<property name="allowEmptyTypes" value="true"/>
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyMethods" value="true"/>
</module>
<module name="OneStatementPerLine"/>
</module>
</module>
15 changes: 15 additions & 0 deletions config/checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">

<suppressions>
<!--
Complexity metrics are aimed at production code. Test code (data-heavy fuzz and
parameterised tests, long arrange blocks) routinely trips them with little value,
so the complexity checks are suppressed for test sources. Import, whitespace and
line-length rules still apply to tests.
-->
<suppress checks="CyclomaticComplexity|NPathComplexity|BooleanExpressionComplexity"
files="[\\/]src[\\/]test[\\/]"/>
</suppressions>
37 changes: 36 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<quarkus.platform.version>3.35.1</quarkus.platform.version>
<skipITs>true</skipITs>
<surefire-plugin.version>3.5.5</surefire-plugin.version>
<maven-checkstyle-plugin.version>3.6.0</maven-checkstyle-plugin.version>
<checkstyle.version>10.21.0</checkstyle.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -158,7 +160,7 @@
<dependency>
<groupId>nl.mijnoverheidzakelijk.ldv</groupId>
<artifactId>logboekdataverwerking-wrapper</artifactId>
<version>1.2.1-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.wiremock</groupId>
Expand Down Expand Up @@ -296,6 +298,39 @@
</systemPropertyVariables>
</configuration>
</plugin>

<!--
Checkstyle gate: the `check` goal is bound to the validate phase and fails the
build on any violation (rule severity is error in config/checkstyle/checkstyle.xml).
Bound to validate so it runs on `mvn test` as well as `mvn verify` and fails fast.
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle.version}</version>
</dependency>
</dependencies>
<configuration>
<configLocation>config/checkstyle/checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<consoleOutput>true</consoleOutput>
<failOnViolation>true</failOnViolation>
</configuration>
<executions>
<execution>
<id>checkstyle-validate</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Loading