Skip to content

Commit b6648c0

Browse files
aksOpsclaudePaperclip-Paperclip
authored
refactor(cli): split EnrichCommand.enrichFromCache into phase helpers (RAN-41) (#73)
The 313-line enrichFromCache method scored cognitive complexity 94 on SonarCloud (S3776, allowed 15) when PR #71 (RAN-23) re-classified it as new code. Even small future edits in this file would re-trip the new-code quality gate. Extracted phases into private helpers, preserving exact ordering, side effects, log lines, exit codes, and determinism: - applyGraphDirOverride — --graph option handling - runLinkerPhase — GraphBuilder + cross-file linkers - runClassifierAndEnrichers — layer / lexical / language enrichment - runServiceDetection — ServiceDetector + node/edge merge - bulkLoadIntoNeo4j — top-level Neo4j orchestration - clearGraph — batched DETACH DELETE - bulkLoadNodes — UNWIND CREATE in NODE_BATCH_SIZE batches - createPrimaryIndex — id index + awaitIndexes - createStubNodesForExternalRefs / flushStubBatches / writeStubBatch - buildValidEdgeMaps / toEdgeProps - bulkLoadEdges — UNWIND MATCH/CREATE batches - createSecondaryIndexes — kind/layer/module/path/fulltext indexes - printCompletionSummary - shutdownQuietly — finally-block dbms shutdown - logStepDone — shared "Done in Xms" line Also lifted magic numbers (batch sizes, await timeout, progress interval, stub-merge Cypher) into named constants and replaced fully-qualified references (java.util.HashSet, ServiceDetector, ObjectMapper) with imports for readability. After refactor each method's cognitive complexity is well under 15 (orchestrator at ~1, largest helper at ~11). Verification: - mvn test -Dskip.npm=true → 3395 tests, 0 failures, 0 errors - mvn spotbugs:check → 0 findings - EnrichCommandTest (4) → still green Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Paperclip <noreply@paperclip.ing>
1 parent 1ae0278 commit b6648c0

1 file changed

Lines changed: 345 additions & 230 deletions

File tree

0 commit comments

Comments
 (0)