Raise quality bar, tighten safety, and align docs/CI for Chronicle Compiler
This PR modernises compiler across three fronts:
-
Docs & guidance
- Refines
AGENTS.mdtables and wording; promotes real-time docs and formal Nine-Box tagging. - Moves requirements/decisions to
src/main/docs/, addsdecision-log.adoc. - Streamlines
README.adoc(adds:sectnums:, renames sections, adds Documentation & Requirements link). - Trims line-wrapping in
LICENSE.adoc.
- Refines
-
Build & quality profile
- Bumps parent to
1.27ea2-SNAPSHOT. - Adds an opt-in
code-reviewMaven profile with Checkstyle, SpotBugs(+FindSecBugs), PMD, and JaCoCo gates (85% line, 85% branch). - Introduces
spotbugs-annotations(provided), rule versions as properties, and suppression files.
- Bumps parent to
-
Runtime compiler hardening & tests
- Tightens class-name validation (allows
module-info/package-info; blocks invalid segments). - Adds safe file resolution and NIO-based IO with backup/restore; never closes
System.err. - Makes compiler options immutable, centralises
StandardJavaFileManagercreation. - Preserves binary compatibility on
fileManagerOverridewhile adding a setter. - Substantial test suite expansion for concurrency, IO, safety rails, and binary compatibility.
- Tightens class-name validation (allows
Motivation
- Reduce false positives and drift by codifying company-wide doc and tagging rules for agents/humans.
- Bring the module up to Chronicle’s current quality bar with a single, reproducible
-Pcode-reviewrun. - Address security and robustness concerns around path handling, writer lifecycle, and class-name acceptance.
- Set realistic, enforced coverage gates that match today’s baseline (85%) while keeping pressure upward.
Notable Changes
Documentation and guidance
-
AGENTS.md: table alignment, clearer Javadoc “Do/Don’t”, line-break hygiene, Nine-Box taxonomy table. -
Requirements/decisions now under
src/main/docs/; links fixed inAGENTS.mdandREADME.adoc. -
decision-log.adocadds:- [RC-FN-001] allow hyphenated descriptor class names.
- [RC-TEST-002] enforce 85% line/branch coverage gates.
-
project-requirements.adoc: JRC-TEST-014 updated to>= 85%. -
README.adoc: concise sections,:sectnums:, adds “Documentation & Requirements” section. -
LICENSE.adoc: compact, single-line paragraphs.
Build and quality
-
New properties: pinned versions for Checkstyle, SpotBugs, FindSecBugs, PMD, JaCoCo, Chronicle quality rules.
-
-Pcode-reviewprofile:- Checkstyle with Chronicle rules, fail on warning.
- SpotBugs + FindSecBugs,
effort=Max,threshold=Low, fail on error; project-local exclude file. - PMD with fail on violation and project-local excludes.
- JaCoCo prepare/report/check with 85% line / 85% branch.
-
Always define JaCoCo version in the
sonarprofile too. -
Adds
spotbugs-annotations(provided scope). -
New config files:
-
src/main/config/spotbugs-exclude.xml(documented suppressions with IDs). -
src/main/config/pmd-exclude.properties(scaffold with justification comments).
-
Runtime compiler changes
-
Class name validation: accepts
module-info/package-info; per-segment regex prevents invalid characters and trailing hyphens. -
Path safety:
safeResolve(...)and sanitisation inCompilerUtilsblock traversal and normalise paths. -
IO: switch to NIO
Path/Files; atomic backup/restore; identical content short-circuit; clearer exceptions. -
Default writer: UTF-8, auto-flush, never closes
System.err. - Compiler options: stored as unmodifiable list.
- Standard file manager: centralised, cached access; diagnostic listener simplified.
-
File manager override: legacy public field retained (now
volatileand documented); newsetFileManagerOverride(...)for source-level use. -
MyJavaFileManager: small refactor; dedicated innerJavaFileObjectclasses; clearer Unsafe initialisation; FB suppressions with justifications. - Minor tidy-ups (imports, lambdas, comments, visibility).
Tests
-
New and expanded suites covering:
- Binary compatibility of
fileManagerOverride. - Multi-threaded compilation with barrier; try-with-resources for classloaders.
- IO round-trips, backups, sanitisation, inline inputs, error paths.
- Guardrailed pipeline example (validation vs compile metrics; cache hits).
-
CachedCompilerbytecode map behaviour on success/failure; manager updates; closing behaviour. -
MyJavaFileManagerbuffering, delegation, modules APIs where present, and invocation edge cases.
- Binary compatibility of
Backward Compatibility
-
Binary: preserved. The public
fileManagerOverridefield remains, nowvolatile; callers can also use the new setter. -
Behavioural:
-
Stricter class-name checks may reject previously accepted but invalid names;
module-info/package-infoare explicitly allowed. -
Path traversal will now be rejected; callers passing unsafe relative paths will see
IllegalArgumentException. - JaCoCo gates raised to 85%/85% under
-Pcode-review(opt-in profile).
-
Stricter class-name checks may reject previously accepted but invalid names;
How to use the quality profile
mvn -q -Pcode-review verify
- Checkstyle, SpotBugs(+FindSecBugs), PMD, and JaCoCo will run and fail on violations.
- Suppressions live under
src/main/config/. Please add targeted entries with justification comments.
Quality Gate passed
Issues
15 New issues
0 Accepted issues
Measures
0 Security Hotspots
80.3% Coverage on New Code
0.0% Duplication on New Code