Repository navigation
feat: add --gate-on-change pre-change CRAP gate (#268) - #293
Conversation
jflowers
left a comment
There was a problem hiding this comment.
AI-assisted review of the --gate-on-change feature (#268). All CI checks pass and all six acceptance criteria are covered; the implementation is clean (pure-function diff parser, isolated gate logic, interface-based git invocation).
Summary of findings (full detail in inline comments):
- [MEDIUM] JSON Schema not updated for new
changed_functionsfields - [MEDIUM]
--gate-on-changesilently ignored when combined with--analyzer - [MEDIUM]
fileMatchesbasename fallback can false-positive on same-named files - [LOW]
strconv.Atoierrors discarded inparseHunkHeader - [LOW]
buildEndLineMapsilently swallows parse errors
None are blocking; verdict is COMMENT.
This review was generated by /uf.review-pr (AI-assisted).
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Remove the basename-only short-circuit in fileMatches that could false-positive on same-named files in different directories, and check strconv.Atoi errors when parsing hunk headers instead of discarding them. Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Log a warning when os.Stat or parser.ParseFile fails instead of silently continuing, which previously forced single-line fallback and could hide coverage false negatives. Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Add an exported CrapSchema documenting the CRAP report JSON contract, including the changed_functions and changed_functions_summary fields added by --gate-on-change. Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Remove the basename-only short-circuit in fileMatches that could false-positive on same-named files in different directories, and check strconv.Atoi errors when parsing hunk headers instead of discarding them. Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Log a warning when os.Stat or parser.ParseFile fails instead of silently continuing, which previously forced single-line fallback and could hide coverage false negatives. Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Add an exported CrapSchema documenting the CRAP report JSON contract, including the changed_functions and changed_functions_summary fields added by --gate-on-change. Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
ad1aac6 to
e35dd1e
Compare
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Remove the basename-only short-circuit in fileMatches that could false-positive on same-named files in different directories, and check strconv.Atoi errors when parsing hunk headers instead of discarding them. Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Log a warning when os.Stat or parser.ParseFile fails instead of silently continuing, which previously forced single-line fallback and could hide coverage false negatives. Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
e35dd1e to
ab49273
Compare
Add an exported CrapSchema documenting the CRAP report JSON contract, including the changed_functions and changed_functions_summary fields added by --gate-on-change. Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Add a new flag to gaze crap that compares CRAP scores against the current working tree baseline, failing the gate when any function's score worsens beyond the configured epsilon. Includes a new internal/diff package for git diff parsing and integration tests. Assisted-by: qwen3.7-plus Generated with AI assistance (qwen3.7-plus)
Assisted-by: qwen3.7-plus Generated with AI assistance (qwen3.7-plus)
The --gate-on-change PR introduced two functions in internal/diff that pushed GazeCRAPload from 6 to 7, failing the CI threshold check (GazeCRAPload: 7/6). - Decompose Parse (complexity 17 -> 9) into pure path/hunk helpers. - Extract diffArgs from (*GitDiffer).Diff (complexity 4 -> 3). GazeCRAPload: 7 -> 5, both new offenders below the GazeCRAP threshold.
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Remove the basename-only short-circuit in fileMatches that could false-positive on same-named files in different directories, and check strconv.Atoi errors when parsing hunk headers instead of discarding them. Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Log a warning when os.Stat or parser.ParseFile fails instead of silently continuing, which previously forced single-line fallback and could hide coverage false negatives. Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Add an exported CrapSchema documenting the CRAP report JSON contract, including the changed_functions and changed_functions_summary fields added by --gate-on-change. Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR unbound-force#293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
ab49273 to
e7f09bd
Compare
jflowers
left a comment
There was a problem hiding this comment.
Note: Could not post as APPROVE due to insufficient permissions (GitHub prohibits self-approval — the PR author cannot approve their own pull request). Posted as COMMENT instead. Original verdict: APPROVE.
Clean implementation of the --gate-on-change feature that scopes CRAP gate evaluation to functions changed in the working tree. All prior review findings (from the earlier COMMENT round) have been addressed in follow-up commits. Build and tests pass locally (go build ./..., go test -race -count=1 -short ./...); MegaLinter is SUCCESS in CI.
Alignment [LOW] — buildEndLineMap in GoComplexityProvider.Analyze runs unconditionally even when --gate-on-change is not active, adding minor parse overhead to the common path. Documented design trade-off (D7); acceptable as-is, no change required.
Security — No issues. GitDiffer.Diff uses exec.CommandContext (no shell), rejects leading-- refs, uses --no-ext-diff, and enforces a 30s timeout.
This review was generated by /uf.review-pr (AI-assisted).
Addresses PR #293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Remove the basename-only short-circuit in fileMatches that could false-positive on same-named files in different directories, and check strconv.Atoi errors when parsing hunk headers instead of discarding them. Addresses PR #293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Log a warning when os.Stat or parser.ParseFile fails instead of silently continuing, which previously forced single-line fallback and could hide coverage false negatives. Addresses PR #293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Add an exported CrapSchema documenting the CRAP report JSON contract, including the changed_functions and changed_functions_summary fields added by --gate-on-change. Addresses PR #293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR #293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR #293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR #293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR #293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR #293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Addresses PR #293 review feedback from @jflowers. Signed-off-by: Jay Flowers <[email protected]> Assisted-by: deepseek-v4-pro
Summary
Add
--gate-on-changeflag togaze crapthat compares CRAP scores against the current working tree baseline, failing the gate when any function's score worsens beyond the configured epsilon. This enables pre-commit/pre-push CI checks that catch CRAP regressions before they reachmain.Closes #268
RFC: https://github.com/orgs/unbound-force/discussions/483
How to Test
How to Demo
gaze crap ./... --gate-on-changeon a clean working tree — should pass with no regressions.gaze crap ./... --gate-on-change— should fail with a clear message showing which function regressed and by how much.Key Files Changed
internal/diff/— new package for git diff parsing (unified diff parser + git invocation wrapper)internal/crap/gatechange.go— new core gate logic: baseline comparison, epsilon thresholding, regression detectioninternal/crap/gatechange_test.go— new unit tests for gate logicinternal/diff/diff.go,internal/diff/git.go— new diff parser and git integration with testscmd/gaze/main.go— wire--gate-on-changeflag intogaze crapcommandcmd/gaze/main_test.go— integration tests for the new flaginternal/crap/analyze.go,internal/crap/crap.go,internal/crap/provider.go— expose changed-file set through analysis pipelineinternal/crap/report.go— text report output for gate resultsinternal/provider/goprovider/complexity.go— filter complexity analysis to changed filesdocs/reference/cli/crap.md— CLI reference documentation for the new flagREADME.md— mention of the new flagopenspec/changes/gate-on-change/— OpenSpec change artifacts (proposal, design, spec, tasks)Documentation website issue already filed: unbound-force/website#290
This PR was generated by /uf.finale (AI-assisted).