-
Notifications
You must be signed in to change notification settings - Fork 1
Refactor ProjectGraphGenerator to expose read-only graph results #459
Copy link
Copy link
Closed
Labels
architectureArchitecture, module boundaries, or dependency directionArchitecture, module boundaries, or dependency directionquality-codeGenerated by Hermes Quality Code for small architecture refactorsGenerated by Hermes Quality Code for small architecture refactorsrefactorCode change that preserves behavior while improving structureCode change that preserves behavior while improving structure
Description
Activity
Metadata
Metadata
Assignees
Labels
architectureArchitecture, module boundaries, or dependency directionArchitecture, module boundaries, or dependency directionquality-codeGenerated by Hermes Quality Code for small architecture refactorsGenerated by Hermes Quality Code for small architecture refactorsrefactorCode change that preserves behavior while improving structureCode change that preserves behavior while improving structure
Problem
ProjectGraphGenerator.generate() returns MutableList at project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/ProjectGraphGenerator.kt:16, although callers only read the generated graph and ProjectGraph itself is immutable.
Why This Matters
The mutable return type leaks construction details across the domain boundary and permits callers to alter generated graph state after creation, increasing coupling and making behavior harder to reason about.
Proposed Change
Change generate() to return List while retaining a private mutable accumulator during construction. Add or update a focused test documenting that the generated graph is consumed as a read-only result.
Files
project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/ProjectGraphGenerator.ktproject-generator/src/test/kotlin/io/github/cdsap/projectgenerator/ProjectGraphGeneratorTest.ktConstraints
Acceptance Criteria
Validation
./gradlew :project-generator:unitTest./gradlew :cli:test./gradlew ktlintCheckNotes
This clarifies the domain boundary: graph construction remains internally mutable, while the generated graph is returned as an immutable domain result. Because the library is published, review downstream source compatibility before applying the signature change.