Skip to content

Commit d705c60

Browse files
gpascucciclaudepaulushcgcjCooper
authored
docs(decisions): Checkstyle posture — turn it on advisory now; how strict do we want it? (#272)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Paulo Gomes da Cruz Junior <paulo.cruz@gov.bc.ca> Co-authored-by: Cooper <sofia.cooper@cgi.com>
1 parent fb08573 commit d705c60

541 files changed

Lines changed: 25393 additions & 15753 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
# provides: AbstractOracleIT starts one gvenzl/oracle-free container per JVM and applies
3636
# the test snapshot with Flyway's Java API.
3737
commands: |
38-
mvn -B -ntp -Dcheckstyle.skip=false -Dskip.integration.tests=false verify checkstyle:checkstyle
38+
mvn -B -ntp -Dskip.integration.tests=false verify
3939
dir: backend
4040
java-cache: maven
4141
java-distribution: temurin

backend/.mvn/google_checks.xml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@
3838
<property name="eachLine" value="true"/>
3939
</module>
4040

41-
<module name="LineLength">
42-
<property name="fileExtensions" value="java"/>
43-
<property name="max" value="100"/>
44-
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
45-
</module>
46-
4741
<module name="TreeWalker">
4842
<module name="OuterTypeFilename"/>
4943
<module name="IllegalTokenText">
@@ -238,14 +232,6 @@
238232
<message key="ws.notPreceded"
239233
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
240234
</module>
241-
<module name="Indentation">
242-
<property name="basicOffset" value="2"/>
243-
<property name="braceAdjustment" value="2"/>
244-
<property name="caseIndent" value="2"/>
245-
<property name="throwsIndent" value="4"/>
246-
<property name="lineWrappingIndentation" value="4"/>
247-
<property name="arrayInitIndent" value="2"/>
248-
</module>
249235
<module name="AbbreviationAsWordInName">
250236
<property name="ignoreFinal" value="false"/>
251237
<property name="allowedAbbreviationLength" value="0"/>
@@ -257,12 +243,6 @@
257243
<module name="NoWhitespaceBeforeCaseDefaultColon"/>
258244
<module name="OverloadMethodsDeclarationOrder"/>
259245
<module name="VariableDeclarationUsageDistance"/>
260-
<module name="CustomImportOrder">
261-
<property name="sortImportsInGroupAlphabetically" value="true"/>
262-
<property name="separateLineBetweenGroups" value="true"/>
263-
<property name="customImportOrderRules" value="STATIC###THIRD_PARTY_PACKAGE"/>
264-
<property name="tokens" value="IMPORT, STATIC_IMPORT, PACKAGE_DEF"/>
265-
</module>
266246
<module name="MethodParamPad">
267247
<property name="tokens"
268248
value="CTOR_DEF, LITERAL_NEW, METHOD_CALL, METHOD_DEF,

backend/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ FROM maven:3.9.16-eclipse-temurin-21 AS build
22

33
WORKDIR /workspace
44
COPY pom.xml ./
5+
COPY .mvn ./.mvn
56
RUN mvn -B -ntp -DskipTests dependency:go-offline
67
COPY src ./src
78
RUN mvn -B -ntp package

backend/pom.xml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,15 @@
6161
<skip.integration.tests>true</skip.integration.tests>
6262
<skip.unit.tests>false</skip.unit.tests>
6363
<jacoco.skip>false</jacoco.skip>
64-
<checkstyle.skip>true</checkstyle.skip>
65-
<checkstyle.failsOnError>false</checkstyle.failsOnError>
64+
<checkstyle.skip>false</checkstyle.skip>
65+
<checkstyle.failsOnError>true</checkstyle.failsOnError>
6666
<checkstyle.includeTestSourceDirectory>false</checkstyle.includeTestSourceDirectory>
6767
<cyclonedx.skip>false</cyclonedx.skip>
6868
<commons-lang3.version>3.20.0</commons-lang3.version>
6969
<jasperreports.version>7.0.8</jasperreports.version>
7070
<sonar.organization>bcgov-sonarcloud</sonar.organization>
7171
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
72+
<sonar.java.checkstyle.reportPaths>target/checkstyle-result.xml</sonar.java.checkstyle.reportPaths>
7273
<!-- Keep Sonar coverage measurement in step with the jacoco instrumentation excludes
7374
below: config/dto/exception/boilerplate are not instrumented, so counting them as
7475
uncovered would understate new-code coverage for lines jacoco never reports on. -->
@@ -510,6 +511,29 @@
510511
</execution>
511512
</executions>
512513
</plugin>
514+
<plugin>
515+
<groupId>com.diffplug.spotless</groupId>
516+
<artifactId>spotless-maven-plugin</artifactId>
517+
<version>2.44.3</version>
518+
<configuration>
519+
<java>
520+
<googleJavaFormat>
521+
<version>1.25.2</version>
522+
<style>GOOGLE</style>
523+
</googleJavaFormat>
524+
<formatAnnotations />
525+
</java>
526+
</configuration>
527+
<executions>
528+
<execution>
529+
<id>spotless-check</id>
530+
<phase>validate</phase>
531+
<goals>
532+
<goal>check</goal>
533+
</goals>
534+
</execution>
535+
</executions>
536+
</plugin>
513537
<plugin>
514538
<groupId>org.apache.maven.plugins</groupId>
515539
<artifactId>maven-checkstyle-plugin</artifactId>
@@ -532,7 +556,7 @@
532556
<executions>
533557
<execution>
534558
<id>validate</id>
535-
<phase>checkstyle</phase>
559+
<phase>validate</phase>
536560
<goals>
537561
<goal>check</goal>
538562
</goals>

backend/src/main/java/ca/bc/gov/nrs/ilcr/BackendConstants.java

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,40 @@
44
import lombok.NoArgsConstructor;
55

66
/**
7-
* Application-wide constants: SQL parameter placeholders, sentinel values, and shared
8-
* security path lists.
7+
* Application-wide constants: SQL parameter placeholders, sentinel values, and shared security path
8+
* lists.
99
*
1010
* <p>The token values in this class indicate an absent or unspecified value (for example when
11-
* binding query parameters) and a placeholder client identifier used when no client is
12-
* available. The path arrays centralize the request matchers referenced by the security
13-
* configuration.</p>
11+
* binding query parameters) and a placeholder client identifier used when no client is available.
12+
* The path arrays centralize the request matchers referenced by the security configuration.
1413
*
15-
* <p>This class is not instantiable and only exposes static constant values.</p>
14+
* <p>This class is not instantiable and only exposes static constant values.
1615
*/
1716
@NoArgsConstructor(access = AccessLevel.PRIVATE)
1817
public class BackendConstants {
1918

2019
/**
2120
* Token representing a missing or unspecified value when interacting with legacy queries.
2221
*
23-
* <p>Used in SQL where clauses and parameter binding to indicate the absence of a filter
24-
* value.</p>
22+
* <p>Used in SQL where clauses and parameter binding to indicate the absence of a filter value.
2523
*/
2624
public static final String NOVALUE = "NOVALUE";
2725

2826
/**
2927
* Token representing the absence of a client value.
3028
*
31-
* <p>Used as a fallback client identifier in places where a client list is required but
32-
* none are available.</p>
29+
* <p>Used as a fallback client identifier in places where a client list is required but none are
30+
* available.
3331
*/
3432
public static final String NOCLIENT = "NOCLIENT";
3533

3634
/**
3735
* Paths permitted without authentication regardless of whether security is enabled.
3836
*
39-
* <p>Referenced by the security filter chain to allow the API root, health, info, and
40-
* metrics endpoints.</p>
37+
* <p>Referenced by the security filter chain to allow the API root, health, info, and metrics
38+
* endpoints.
4139
*/
4240
public static final String[] PUBLIC_PATHS = {
43-
"/api",
44-
"/api/health",
45-
"/api/health/**",
46-
"/api/info",
47-
"/api/prometheus"
41+
"/api", "/api/health", "/api/health/**", "/api/info", "/api/prometheus"
4842
};
4943
}

backend/src/main/java/ca/bc/gov/nrs/ilcr/HealthCheck.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@
44
import java.net.URI;
55
import java.time.Duration;
66

7+
/** Simple application health check utility. */
78
public final class HealthCheck {
89
private static final int HEALTHY = 0;
910
private static final int UNHEALTHY = 1;
1011

1112
private HealthCheck() {}
1213

14+
/**
15+
* Main entry point for the health check.
16+
*
17+
* @param args command line arguments
18+
*/
1319
public static void main(String[] args) {
1420
try {
1521
int port = Integer.parseInt(System.getenv().getOrDefault("SERVER_PORT", "8080"));

backend/src/main/java/ca/bc/gov/nrs/ilcr/IlcrBackendApplication.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,23 @@
44
import org.springframework.boot.SpringApplication;
55
import org.springframework.boot.autoconfigure.SpringBootApplication;
66

7+
/** The main entry point for the ILCR Backend Application. */
78
@SpringBootApplication
89
public class IlcrBackendApplication {
910

10-
public static void main(String[] args) {
11-
// Anchor the JVM to Pacific BEFORE the context refreshes. The app serves the BC Ministry of
12-
// Forests, but its OpenShift containers default to UTC, which shifts date boundaries
13-
// (reporting-year rollover, SYSDATE/audit timestamps read as java.util.Date). Setting it here
14-
// — ahead of SpringApplication.run — is deterministic: logging init, the Hikari pool, and every
15-
// bean's @PostConstruct all observe Pacific, with no startup window left in UTC. Deploy may
16-
// also set TZ=America/Vancouver on the container; this guarantees it even when it doesn't.
17-
TimeZone.setDefault(TimeZone.getTimeZone("America/Vancouver"));
18-
SpringApplication.run(IlcrBackendApplication.class, args);
19-
}
11+
/**
12+
* The main method to start the Spring Boot application.
13+
*
14+
* @param args the command line arguments
15+
*/
16+
public static void main(String[] args) {
17+
// Anchor the JVM to Pacific BEFORE the context refreshes. The app serves the BC Ministry of
18+
// Forests, but its OpenShift containers default to UTC, which shifts date boundaries
19+
// (reporting-year rollover, SYSDATE/audit timestamps read as java.util.Date). Setting it here
20+
// — ahead of SpringApplication.run — is deterministic: logging init, the Hikari pool, and every
21+
// bean's @PostConstruct all observe Pacific, with no startup window left in UTC. Deploy may
22+
// also set TZ=America/Vancouver on the container; this guarantees it even when it doesn't.
23+
TimeZone.setDefault(TimeZone.getTimeZone("America/Vancouver"));
24+
SpringApplication.run(IlcrBackendApplication.class, args);
25+
}
2026
}

backend/src/main/java/ca/bc/gov/nrs/ilcr/assignment/MillUserProfileXrefEntity.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
/**
1010
* Spring Data JDBC row shape for {@code THE.ILCR_MILL_USER_PROFILE_XREF} — one submitter↔mill
1111
* assignment (Story 2.1, AD-3). FAM is the source of truth for identity: {@code USER_GUID} is the
12-
* FAM {@code custom:idp_user_id} (32-char IDIR/BCeID GUID, Story 1.0), with no FK to any user table.
13-
* {@code USER_DISPLAY_NAME}/{@code IDP_USERNAME} are snapshotted from FAM at assign time (Q5) so an
14-
* ended assignment whose user has left FAM still renders. {@code END_DATE} null ⇒ ACTIVE.
12+
* FAM {@code custom:idp_user_id} (32-char IDIR/BCeID GUID, Story 1.0), with no FK to any user
13+
* table. {@code USER_DISPLAY_NAME}/{@code IDP_USERNAME} are snapshotted from FAM at assign time
14+
* (Q5) so an ended assignment whose user has left FAM still renders. {@code END_DATE} null ⇒
15+
* ACTIVE.
1516
*
16-
* <p>{@link MillUserProfileXrefRepository} reads these; the service maps them to the wire
17-
* {@code MillSubmitter} DTO (Story 2.2 — entities never cross the service boundary).
17+
* <p>{@link MillUserProfileXrefRepository} reads these; the service maps them to the wire {@code
18+
* MillSubmitter} DTO (Story 2.2 — entities never cross the service boundary).
1819
*/
1920
@Table(name = "ILCR_MILL_USER_PROFILE_XREF", schema = "THE")
2021
public record MillUserProfileXrefEntity(
@@ -29,5 +30,4 @@ public record MillUserProfileXrefEntity(
2930
@Column("ENTRY_USERID") String entryUserid,
3031
@Column("ENTRY_TIMESTAMP") LocalDateTime entryTimestamp,
3132
@Column("UPDATE_USERID") String updateUserid,
32-
@Column("UPDATE_TIMESTAMP") LocalDateTime updateTimestamp) {
33-
}
33+
@Column("UPDATE_TIMESTAMP") LocalDateTime updateTimestamp) {}

backend/src/main/java/ca/bc/gov/nrs/ilcr/assignment/MillUserProfileXrefRepository.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,22 @@
1111
* named-parameter SQL). SQL only — decisions live in the service; entities never cross the service
1212
* boundary (the service maps them to the {@code MillSubmitter} DTO in Story 2.2).
1313
*
14-
* <p>Story 2.1 scaffolds the read side; the assign/end write methods and the mill-join enrichment are
15-
* added in Story 2.2. These reads are exercised (red) by Story 2.2's tests.
14+
* <p>Story 2.1 scaffolds the read side; the assign/end write methods and the mill-join enrichment
15+
* are added in Story 2.2. These reads are exercised (red) by Story 2.2's tests.
1616
*/
1717
@org.springframework.stereotype.Repository
18-
public interface MillUserProfileXrefRepository
19-
extends Repository<MillUserProfileXrefEntity, Long> {
18+
public interface MillUserProfileXrefRepository extends Repository<MillUserProfileXrefEntity, Long> {
2019

2120
/**
22-
* All assignment rows for a mill — active (END_DATE null) and ended — most-recently-started first.
23-
* The service filters/derives status and joins {@code THE.MILL} for the mill number/name (2.2).
21+
* All assignment rows for a mill — active (END_DATE null) and ended — most-recently-started
22+
* first. The service filters/derives status and joins {@code THE.MILL} for the mill number/name
23+
* (2.2).
2424
*
2525
* @param millId the {@code ILCR_MILL_ID}
2626
* @return the mill's assignment rows
2727
*/
28-
@Query("""
28+
@Query(
29+
"""
2930
SELECT ILCR_MILL_USER_PROFILE_XREF_ID, USER_GUID, ILCR_MILL_ID, USER_DISPLAY_NAME, IDP_USERNAME,
3031
START_DATE, END_DATE, REVISION_COUNT, ENTRY_USERID, ENTRY_TIMESTAMP, UPDATE_USERID,
3132
UPDATE_TIMESTAMP
@@ -36,12 +37,14 @@ public interface MillUserProfileXrefRepository
3637
List<MillUserProfileXrefEntity> findByMill(@Param("millId") long millId);
3738

3839
/**
39-
* All assignment rows for a submitter (by FAM {@code custom:idp_user_id}) — the user-centric read.
40+
* All assignment rows for a submitter (by FAM {@code custom:idp_user_id}) — the user-centric
41+
* read.
4042
*
4143
* @param userGuid the FAM user GUID ({@code USER_GUID})
4244
* @return the submitter's assignment rows
4345
*/
44-
@Query("""
46+
@Query(
47+
"""
4548
SELECT ILCR_MILL_USER_PROFILE_XREF_ID, USER_GUID, ILCR_MILL_ID, USER_DISPLAY_NAME, IDP_USERNAME,
4649
START_DATE, END_DATE, REVISION_COUNT, ENTRY_USERID, ENTRY_TIMESTAMP, UPDATE_USERID,
4750
UPDATE_TIMESTAMP
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package ca.bc.gov.nrs.ilcr.assignment.dto;
22

33
/**
4-
* Wire shape for assigning a submitter to a mill (AD-12 pin, Story 2.1). The mill is a path variable
5-
* and the acting admin is the JWT principal, so the body carries only the submitter's FAM user GUID
6-
* ({@code custom:idp_user_id}). Consumed by Story 2.2's {@code POST /api/v1/mills/{millId}/submitters}.
4+
* Wire shape for assigning a submitter to a mill (AD-12 pin, Story 2.1). The mill is a path
5+
* variable and the acting admin is the JWT principal, so the body carries only the submitter's FAM
6+
* user GUID ({@code custom:idp_user_id}). Consumed by Story 2.2's {@code POST
7+
* /api/v1/mills/{millId}/submitters}.
78
*
89
* @param userGuid the FAM user GUID of the submitter to assign
910
*/
10-
public record AssignSubmitterRequest(String userGuid) {
11-
}
11+
public record AssignSubmitterRequest(String userGuid) {}

0 commit comments

Comments
 (0)