Goal
Reduce cyclomatic complexity in:
cmd/grovegrid/main.go function main() (reported complexity 36)
cmd/grovegrid/main.go function parseCSV() (reported complexity 19)
Target: get both below the Go Report Card / gocyclo warning threshold (>15), or at least significantly closer while keeping behavior identical.
Why
High complexity makes changes risky and discourages contributors. Smaller functions with clear responsibilities are easier to test and evolve.
Scope
Behavior-preserving refactor (no feature changes):
- Extract CLI parsing / validation into a small function (e.g.
parseFlags()).
- Extract filesystem concerns (discover CSV files, sort slices, create output dir).
- Split
parseCSV() into smaller steps:
- open/read
- delimiter detection
- header normalization
- row mapping + validation
- numeric parsing + condition mapping
- Consider moving parsing helpers into a dedicated file/package (even within
cmd/grovegrid/ is fine).
Acceptance criteria
Notes / hints
If tests are missing, it’s okay to add a small regression test first (even one fixture) before refactoring aggressively.
Goal
Reduce cyclomatic complexity in:
cmd/grovegrid/main.gofunctionmain()(reported complexity 36)cmd/grovegrid/main.gofunctionparseCSV()(reported complexity 19)Target: get both below the Go Report Card / gocyclo warning threshold (>15), or at least significantly closer while keeping behavior identical.
Why
High complexity makes changes risky and discourages contributors. Smaller functions with clear responsibilities are easier to test and evolve.
Scope
Behavior-preserving refactor (no feature changes):
parseFlags()).parseCSV()into smaller steps:cmd/grovegrid/is fine).Acceptance criteria
go test ./...passesNotes / hints
If tests are missing, it’s okay to add a small regression test first (even one fixture) before refactoring aggressively.