Repository navigation
feat: add FixStrategy field to CRAP scores for actionable remediation guidance - #49
Merged
Merged
Conversation
… guidance Add deterministic remediation labels to each CRAPload function: - decompose: complexity >= threshold, coverage alone can't help - add_tests: zero coverage, complexity below threshold - add_assertions: Q3 quadrant (has line coverage, lacks contract assertions) - decompose_and_test: high complexity AND zero coverage FixStrategy computed in assignFixStrategy, accumulated as FixStrategyCounts in Summary. Text report shows 'Remediation Breakdown' section and [strategy] labels on worst offenders. JSON output includes new fields automatically via struct tags. Addresses unbound-force#42, unbound-force#44, unbound-force#48
… additions The coverage profile test fixtures referenced crap.go line numbers (89, 92, 97, 105) that shifted when the FixStrategy type and constants were added to crap.go. Updated to current positions (124, 128, 134, 148).
This was referenced Mar 15, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FixStrategyfield tocrap.ScoreandFixStrategyCountstocrap.Summary[strategy]labels on worst offendersMotivation
The gaze report tells users what is wrong (high CRAP scores, Q4 quadrant) but not how to fix it. Users waste time on the wrong remediation strategy:
The fix strategy is deterministic from the CRAP formula and existing metrics -- no new analysis needed.
Fix Strategies
decomposeadd_testsadd_assertionsdecompose_and_testNew Fields
Score.FixStrategy(fix_strategy, omitempty) -- nil for healthy functions, populated for CRAPload functions.Summary.FixStrategyCounts(fix_strategy_counts, omitempty) -- map of strategy to count, e.g.{"decompose": 3, "add_tests": 5}.Tests
8 new tests: 5 for
assignFixStrategy(all 4 strategies + below-threshold nil), 1 forcomputeScoresintegration, 1 forbuildSummaryaccumulation, 1 for text report display.Addresses
fix_strategyfield for automated workflows