Skip to content

chore: reduce CRAPload fragility — cover 19 zero-coverage functions at CRAP >= 30 #166

Description

@yvonnedevlinrh

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

  1. 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.
  2. Decompose the worst offenders: BuildContractCoverageFunc (complexity 22, CRAP 506) and matchContainerUnwrap (complexity 50, CRAP 55) need structural decomposition before tests are practical.
  3. Goal: Reduce CRAPload from 38 to ~30, giving a buffer of 8 functions before the threshold is reached again.

Context

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

Status
In Progress 📋

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions