CRAPload at threshold boundary: 19 functions with 0% coverage and CRAP >= 30
Problem
The CI CRAPload threshold is --max-crapload=38 and main is at exactly CRAPload: 38/38. There are 19 functions with 0% line coverage and CRAP scores >= 30, plus 3 more in the 25-29 range that could tip over with minor complexity changes.
This makes the threshold gate fragile — any bug fix or feature that adds even one branch to a zero-coverage function risks breaking CI, as discovered in #131 (PR #160) where a single && condition increased detectP1CallEffects complexity from 14 to 15 and caused a CRAPload breach.
With 0% coverage, CRAP scores are computed as complexity² + complexity, so complexity increases are amplified quadratically. Even modest coverage (e.g., 50%) would dramatically reduce CRAP scores and create headroom for legitimate complexity growth.
Functions at CRAP >= 30 with 0% coverage (19 total)
| Function |
Complexity |
CRAP |
Fix Strategy |
crap.BuildContractCoverageFunc |
22 |
506.0 |
decompose_and_test |
aireport.runQualityForPackage |
10 |
110.0 |
add_tests |
crap.analyzePackageCoverage |
10 |
110.0 |
add_tests |
aireport.runQualityStep |
8 |
72.0 |
add_tests |
aireport.runClassifyStep |
8 |
72.0 |
add_tests |
crap.loadTestPackage |
8 |
72.0 |
add_tests |
analysis.detectASTReceiverMutations |
24 |
67.0 |
decompose |
quality.matchContainerUnwrap |
50 |
55.2 |
decompose |
main.runCrap |
21 |
51.0 |
decompose |
main.(analyzeModel).Update |
6 |
42.0 |
add_tests |
aireport.resolvePackagePaths |
6 |
42.0 |
add_tests |
crap.resolvePackagePaths |
6 |
42.0 |
add_tests |
quality.WriteText |
32 |
39.9 |
decompose |
analysis.isPointerArgStore |
13 |
34.1 |
add_tests |
report.writeOneResult |
32 |
32.3 |
decompose |
quality.matchAssertionToEffect |
25 |
32.2 |
decompose |
quality.isTransformationCall |
26 |
31.4 |
decompose |
main.findModuleRoot |
5 |
30.0 |
add_tests |
aireport.loadTestPackageForQuality |
5 |
30.0 |
add_tests |
Functions at risk (CRAP 25-29, 0% coverage)
| Function |
Complexity |
CRAP |
Fix Strategy |
quality.resolveSSAValueToObj |
11 |
29.4 |
add_tests |
quality.Assess |
25 |
27.8 |
decompose |
loader.LoadModule |
7 |
27.7 |
add_tests |
Suggested approach
- High-value targets first: The 10
add_tests functions have low complexity (5-13) — even basic coverage would drop them well below the threshold and create CRAPload headroom.
- Decompose the worst offenders:
BuildContractCoverageFunc (complexity 22, CRAP 506) and matchContainerUnwrap (complexity 50, CRAP 55) need structural decomposition before tests are practical.
- Goal: Reduce CRAPload from 38 to ~30, giving a buffer of 8 functions before the threshold is reached again.
Context
CRAPload at threshold boundary: 19 functions with 0% coverage and CRAP >= 30
Problem
The CI CRAPload threshold is
--max-crapload=38andmainis at exactlyCRAPload: 38/38. There are 19 functions with 0% line coverage and CRAP scores >= 30, plus 3 more in the 25-29 range that could tip over with minor complexity changes.This makes the threshold gate fragile — any bug fix or feature that adds even one branch to a zero-coverage function risks breaking CI, as discovered in #131 (PR #160) where a single
&&condition increaseddetectP1CallEffectscomplexity from 14 to 15 and caused a CRAPload breach.With 0% coverage, CRAP scores are computed as
complexity² + complexity, so complexity increases are amplified quadratically. Even modest coverage (e.g., 50%) would dramatically reduce CRAP scores and create headroom for legitimate complexity growth.Functions at CRAP >= 30 with 0% coverage (19 total)
crap.BuildContractCoverageFuncaireport.runQualityForPackagecrap.analyzePackageCoverageaireport.runQualityStepaireport.runClassifyStepcrap.loadTestPackageanalysis.detectASTReceiverMutationsquality.matchContainerUnwrapmain.runCrapmain.(analyzeModel).Updateaireport.resolvePackagePathscrap.resolvePackagePathsquality.WriteTextanalysis.isPointerArgStorereport.writeOneResultquality.matchAssertionToEffectquality.isTransformationCallmain.findModuleRootaireport.loadTestPackageForQualityFunctions at risk (CRAP 25-29, 0% coverage)
quality.resolveSSAValueToObjquality.Assessloader.LoadModuleSuggested approach
add_testsfunctions have low complexity (5-13) — even basic coverage would drop them well below the threshold and create CRAPload headroom.BuildContractCoverageFunc(complexity 22, CRAP 506) andmatchContainerUnwrap(complexity 50, CRAP 55) need structural decomposition before tests are practical.Context
--max-crapload=38(set in.github/workflows/test.yml)http.ResponseWriter.Write()double-counts as bothWriterOutputandHTTPResponseWrite#131, PR fix: prevent http.ResponseWriter.Write() double-count as WriterOutput and HTTPResponseWrite #160