Context
Four report formatting functions in internal/crap/ were extracted during the q4-complexity-reduction work (decomposition of crap.WriteText from CC 18 to CC 2). The extracted helpers are small, focused functions with zero direct test coverage. Adding tests for these functions improves confidence in report output correctness and prevents regressions.
Related: codebase audit from #166 triage
Functions
| Function |
File |
Lines |
Description |
writeScoreTable |
internal/crap/report.go |
~36 |
Renders the CRAP score table with columns for CRAP, complexity, coverage, function name, and location |
writeWorstSection |
internal/crap/report.go |
~32 |
Renders the "Worst Offenders" section with fix strategy labels |
writeRemediationSection |
internal/crap/report.go |
~13 |
Renders the "Remediation Breakdown" section with strategy counts |
writeSSADiagnostics |
internal/crap/report.go |
~11 |
Renders SSA degradation warnings listing affected packages |
Approach
All four functions write to an io.Writer and accept structured data (slices of crap.Score, crap.Summary). Tests should:
- Construct synthetic
Score and Summary values
- Call each function with a
bytes.Buffer
- Assert the output contains expected column headers, values, and formatting
- Verify 80-column width compliance (per project convention)
Acceptance Criteria
Context
Four report formatting functions in
internal/crap/were extracted during theq4-complexity-reductionwork (decomposition ofcrap.WriteTextfrom CC 18 to CC 2). The extracted helpers are small, focused functions with zero direct test coverage. Adding tests for these functions improves confidence in report output correctness and prevents regressions.Related: codebase audit from #166 triage
Functions
writeScoreTableinternal/crap/report.gowriteWorstSectioninternal/crap/report.gowriteRemediationSectioninternal/crap/report.gowriteSSADiagnosticsinternal/crap/report.goApproach
All four functions write to an
io.Writerand accept structured data (slices ofcrap.Score,crap.Summary). Tests should:ScoreandSummaryvaluesbytes.BufferAcceptance Criteria
testing.Short()guardsgo test -race -count=1 -short ./internal/crap/...passesgolangci-lint runreports zero issues