fix: refactor graphwriter to separate dot rendering from file i/o - #444
Merged
cdsap merged 1 commit intoSep 5, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem
project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/writer/GraphWriter.ktmixes pure dependency-graph → DOT string construction with filesystem side effects (File.createNewFile(),writeText,println). There is no unit test of the DOT content—onlyProjectGeneratorTestasserts thatgraph.dotexists. Elsewhere the repo already separates content builders from writers (SettingsGradle.get(),AndroidToml.toml(), CLIGenerateVersionsYaml.render()).Why this matters
Graph edge labels and include paths depend on
NameMappings; regressions in DOT output are hard to catch without spinning up full project generation. Coupling rendering to disk also blocks testing naming/edge cases in isolation and blurs the writer adapter vs. domain presentation boundary.Proposed change
Extract a pure
render(nodes: List<ProjectGraph>): String(or equivalent) onGraphWriterthat builds the digraph body; keepwrite()as a thin adapter that creates$path/graph.dotand writes that string. Add a focused unit test asserting edge lines for a small fixed graph (with controlledNameMappingslikeProjectWriterTestalready does). Do not change DOT format, file path, or call sites inProjectGenerator.Notes
Clean architecture: treat DOT serialization as a pure presentation of the
ProjectGraphdomain model; leavejava.io.Filein the infrastructure adapter. This is a single-boundary, incremental step—not a rewrite of the writer layer.Fixes #443
Changes
project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/writer/GraphWriter.ktproject-generator/src/test/kotlin/io/github/cdsap/projectgenerator/writer/GraphWriterTest.ktVerification
./gradlew :project-generator:unitTest./gradlew :cli:test./gradlew ktlintCheck