cleanup(ocr): use %n instead of \n in TrainingDataExportService format string #474
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
SpotBugs (BAD_PRACTICE category) reports:
The export service writes training data with
String.format("...\n", ...)(or similar). On Windows/CI runners (CI runs onubuntu-latestso this is fine today, but the project also has Windows-using contributors perfrontend/Dockerfilementioning cross-platform) the resulting file has mixed line endings if combined with native writers that emit\r\n.Pure code-hygiene fix. Smallest issue in the audit; bundling for completeness.
Approach
Replace
\ninString.format/printf/Formattercalls with%n. The latter resolves to the platform line separator and matches whatBufferedWriter.newLine()would emit alongside.If the file format is intended to be Unix line endings regardless of platform (likely, since training tools are typically Unix-first), then leave
\nand add a SpotBugs suppression with a@SuppressFBWarnings("VA_FORMAT_STRING_USES_NEWLINE")annotation + a one-line comment explaining the intent. Either fix is correct; the bug is "make the choice explicit."Critical files
backend/src/main/java/org/raddatz/familienarchiv/ocr/TrainingDataExportService.java(line ~28)backend/spotbugs-exclude.xmlif you go the suppression route (created in the new devops(ci) SAST issue)Verification
VA_FORMAT_STRING_USES_NEWLINEfinding disappears../mvnw test -Dtest='*TrainingDataExport*'.Acceptance criteria
%n(platform line ending) or an explicit suppression with rationale exists for keeping\n(Unix-required output format).Effort
XS — 5 minutes.
Risk if not addressed
None operationally. Cleanup-only; bundled with the audit roadmap for completeness.
Tracked in audit doc as F-37 (Low) — new dynamic finding from SpotBugs SAST.