refactor: post-0.59 cleanup — dedup architecture/toml/fs utils merged in last 24h#590
Merged
Conversation
…tor tails) detectCargoWorkspace and detectUvWorkspace shared a byte-identical members- resolution tail (parsed when readable → absent for an explicitly-empty `[]` → unreadable otherwise), differing only in the reader fn, table, label, and config filename. Extract it into one helper both call after their own (differing) pre-checks. Behavior-preserving; the six detectors otherwise stay separate (their file-format bodies are irreducible — merging further would be over-abstraction). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
singleRepoTarget and leafTarget were identical but for the directory they skeletonize and the path they render to. Fold the shared fingerprint→skeleton→ render wiring into one skeletonTarget(directory, path); the two stay as thin, self-documenting wrappers. Behavior-preserving. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…amble) renderDocument and renderRootIndex each hand-built the identical `---<generator> <fingerprint>---\n\n# Architecture` preamble — the serialization side of the contract that readDocumentFingerprint / isSafewordOwned and the standalone hook parser read back. Route both through one architectureFrontmatter(fingerprint) so a future change to the ownership/fingerprint head can't drift between the two renderers. Byte-identical output (parity + nudge tests confirm). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
It was only exercised transitively via the Python test-plan path, unlike its siblings findInTree/indexFilesInTree which have direct tests. Characterize it — root/subdir match, no-match, maxDepth, and (the load-bearing one) that excluded + hidden directories are skipped — as the safety net for the next refactor. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
getScannableSubdirectories and scanTreeForMatch each inlined the same "is a dir safe to recurse into" predicate (not hidden, not in SUBDIRECTORY_ EXCLUDE). Extract isScannableSubdirectory(entry) so the exclude rule lives in one place — a future change (e.g. excluding symlinks) can't drift between the two walkers, exactly the hazard fs.ts's own docs warn about. Behavior-preserving; covered by the findFileMatchingInTree tests added in the prior commit. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
hasTomlTableKey and readTomlTableString each re-implemented the same table-scoped line scan (split → strip comment → trim → track inTable via [headers]). Extract a linesInTable(content, table) generator that yields the in-table lines; both readers consume it and keep only their own per-line logic. Surfaced by /audit (jscpd) — toml.ts was outside the original scout set. Behavior-preserving; covered by the toml + cargo/pyproject manifest tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Behavior-preserving cleanup of the CLI-src code merged over the last 24h (the architecture / test-plan / toml cluster from #560–#578). Six commits, each one-change → test → commit, scouted by three parallel read-only passes + an /audit catch-net.
Refactors (all Tier-1/2 Extract Function, no behavior change)
1549ee29resolveTomlWorkspaceMembers— fold the byte-identical Cargo + uv detector tailsadbe8995skeletonTarget— fold near-identicalsingleRepoTarget/leafTargetfc156423architectureFrontmatter— one writer for the doc preamble (the serialization side of a parsed contract)4506f025findFileMatchingInTreecoverage (safety net for the next commit)f135b140isScannableSubdirectory— share the dir-exclude predicate across the fs tree-walkerse20db8adlinesInTablegenerator — dedup the TOML table traversal (surfaced by /audit jscpd)Deliberately NOT done (over-abstraction / already-mitigated)
Verification
🤖 Generated with Claude Code