Skip to content

feat: complete Spec 003 remaining tasks and activate GazeCRAP (Spec 004 Phase 7) - #4

Merged
jflowers merged 5 commits into
mainfrom
003-test-quality-metrics-remaining
Feb 23, 2026
Merged

jflowers merged 5 commits into
mainfrom
003-test-quality-metrics-remaining

Conversation

@jflowers

Copy link
Copy Markdown
Collaborator

Summary

  • Complete all remaining Spec 003 tasks (66/66 done): multi-library assertion mapping, testing.Short() detection, benchmarks, and edge-case coverage
  • Activate GazeCRAP computation in crap.Analyze() via new ContractCoverageFunc option (Spec 004 T050)
  • Add gaze self-check command for dogfooding CRAP analysis on Gaze's own source (T054)
  • Add 21-case GazeCRAP formula accuracy test suite (SC-002), quadrant breakdown output tests (T053), and self-check tests (T055)

Changes

Spec 003 — Test Quality Metrics (commit f4d2866)

  • Multi-library assertion mapping (internal/quality/mapping.go): Recognize assert.*, require.*, cmp.Equal/Diff as assertion calls in addition to testing.T methods
  • testing.Short() detection (internal/quality/pairing.go): Mark test functions calling testing.Short() as conditional-skip tests
  • Benchmarks (internal/quality/bench_test.go): 5 benchmarks for core quality assessment functions
  • Test fixtures (internal/quality/testdata/src/multilib/): New multi-library test fixture exercising testify, go-cmp, and custom assertion patterns
  • Edge-case tests (internal/quality/quality_test.go): 322+ lines of new test coverage including multi-assertion, skip detection, and boundary cases

Spec 004 Phase 7 — GazeCRAP Activation (commit 90fde1b)

  • ContractCoverageFunc field on crap.Options: Callback that provides per-function contract coverage; when set, Analyze() populates GazeCRAP, ContractCoverage, and Quadrant on each Score
  • gaze self-check command: Runs full CRAP pipeline on Gaze's own source with --format, --max-crapload, --max-gaze-crapload flags
  • GazeCRAP formula tests: 21 hand-computed (complexity, contractCovPct) → GazeCRAP pairs validating SC-002 to ±0.01 tolerance
  • Quadrant breakdown test: Verifies WriteText() renders quadrant section and fits 80-column terminal
  • Task bookkeeping: All Spec 004 Phase 7 tasks (T050–T055) marked complete

Testing

All tests pass with go test -race -count=1 -short ./.... Integration tests (TestRunSelfCheck_TextFormat/JSONFormat) are gated behind !testing.Short() due to running the full coverage pipeline.

Implement remaining 9 tasks: discarded return detection (T032),
multilib fixture with stub testify/go-cmp packages (T058), CLI
integration tests (T052), acceptance tests for SC-001 through
SC-007 (T059-T065), and benchmarks (T066).

Fix walkCalls to follow MakeClosure instructions, enabling target
inference inside t.Run closures for table-driven test support.
…tests

Wire ContractCoverageFunc into crap.Analyze() to populate GazeCRAP,
ContractCoverage, and Quadrant fields when contract coverage data is
available (T050). Add gaze self-check command for dogfooding CRAP
analysis on Gaze's own source (T054). Complete GazeCRAP formula
accuracy tests (T052/SC-002), quadrant breakdown output tests (T053),
and self-check tests (T055). Mark all Spec 004 Phase 7 tasks done.
@github-actions

github-actions Bot commented Feb 23, 2026 •

Copy link
Copy Markdown

✅⚠️MegaLinter analysis: Success with warnings

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ GO golangci-lint yes yes no no 22.42s
✅ GO revive 12 0 0 0.53s
⚠️ MARKDOWN markdownlint 1 0 16 0 0.84s
✅ REPOSITORY gitleaks yes no no 0.63s
✅ REPOSITORY git_diff yes no no 0.27s
✅ YAML yamllint 1 0 0 0.71s

Detailed Issues

⚠️ MARKDOWN / markdownlint - 16 errors
AGENTS.md:44 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
AGENTS.md:49:11 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:49:21 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:49:1 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]
AGENTS.md:49:11 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]
AGENTS.md:74 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
AGENTS.md:95:401 error MD013/line-length Line length [Expected: 400; Actual: 409]
AGENTS.md:127:9 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:127:19 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:127:29 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:127:43 error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]
AGENTS.md:127:1 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]
AGENTS.md:127:9 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]
AGENTS.md:127:19 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]
AGENTS.md:127:29 error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]
AGENTS.md:137 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]

See detailed reports in MegaLinter artifacts
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

Resolve 14 findings across 3 review iterations:

- SC-003 acceptance test: add ratchet floor with t.Errorf and TODO #5
- Package-level cache: move to TestMain-scoped fixtureCache with nil guards
- FindTargetCall: add sameFunction() to prevent cross-package false matches
- loadTestPackage: return error instead of silent fallback to non-test pkg
- TestRunQuality_ThresholdFail: assert err != nil instead of discarding
- FR-015 warning: update stale message to actionable guidance
- AssertionNilCheck: add missing nil_check constant, kind, and schema enum
- runSelfCheck: use findModuleRoot() to walk up to go.mod
- checkQualityThresholds: return all failures, not just the first
- BuildTestSSA: remove unused ssaProg (Feature Zombie)
- QualitySchema: add discarded_returns to ContractCoverage definition
- tasks.md T050/T054: document GazeCRAP CLI wiring as deferred
Split the single CI test job into two parallel jobs:
- Unit + Integration: runs with -short flag (skips self-check)
- E2E: runs TestRunSelfCheck with 20m timeout

The self-check tests spawn 'go test -coverprofile' on the full
module, which takes 7+ minutes and exceeds the default 10m CI
timeout. Running them in a dedicated job with an extended timeout
prevents the main test suite from being blocked.

Document the test suite convention in AGENTS.md.
The go test subprocess spawned by generateCoverProfile was running
the full test suite (including integration tests) without -short,
causing 20+ minute runtimes that exceeded CI timeouts. Adding -short
skips self-check tests in the subprocess (preventing infinite
recursion) while still producing sufficient coverage data for CRAP
score computation.
@jflowers
jflowers merged commit e498844 into main Feb 23, 2026
3 checks passed
@jflowers
jflowers deleted the 003-test-quality-metrics-remaining branch February 23, 2026 12:01
jflowers added a commit to jflowers/gaze that referenced this pull request Aug 12, 2026
- Fix skipped test data missing from report pipeline quality JSON:
  BuildPackageSummary only aggregates report-level data, so
  SkippedTests/SkippedTestNames are now set post-hoc in
  runQualityStep and propagated through ReportSummary (#2, unbound-force#5)
- Add combined threshold test for --min-contract-coverage +
  --max-over-specification both set on empty results (#1)
- Add divergence edge case test: SkippedTests > len(SkippedTestNames)
  verifies defensive guard prevents out-of-bounds (unbound-force#3)
- Extract shared MaxSkippedTestDisplay constant from quality package,
  replacing duplicate magic 20 in main.go and report.go (unbound-force#6)
- Move totalTestFuncs computation inside text format branch where
  it is actually used (unbound-force#8)
- Wrap WriteJSON/WriteText errors with context per CS-006 (unbound-force#9)
- Filed follow-up issue unbound-force#219 for multi-package mixed BDD+normal
  scenario test (unbound-force#4)
jflowers added a commit to jflowers/gaze that referenced this pull request Aug 13, 2026
…nbound-force#4, unbound-force#7)

- Align quality zero-result error message to match gaze crap pattern:
  'no test-target pairs resolved — cannot evaluate thresholds' (unbound-force#7)
- Add TestMergeSummaries_SkippedTestsDivergence to exercise defensive
  guard when SkippedTests > len(SkippedTestNames) (unbound-force#3)
- Add TestMergeSummaries_MultiPackage_AggregatesSkipped for
  mergeSummaries aggregation coverage
- Add TestRunQuality_MixedBDDAndNormalPackages for mixed BDD + normal
  multi-package scenario (unbound-force#4)
- Update 3 existing test assertions for new error message wording
jflowers added a commit to jflowers/gaze that referenced this pull request Aug 13, 2026
- Fix skipped test data missing from report pipeline quality JSON:
  BuildPackageSummary only aggregates report-level data, so
  SkippedTests/SkippedTestNames are now set post-hoc in
  runQualityStep and propagated through ReportSummary (#2, unbound-force#5)
- Add combined threshold test for --min-contract-coverage +
  --max-over-specification both set on empty results (#1)
- Add divergence edge case test: SkippedTests > len(SkippedTestNames)
  verifies defensive guard prevents out-of-bounds (unbound-force#3)
- Extract shared MaxSkippedTestDisplay constant from quality package,
  replacing duplicate magic 20 in main.go and report.go (unbound-force#6)
- Move totalTestFuncs computation inside text format branch where
  it is actually used (unbound-force#8)
- Wrap WriteJSON/WriteText errors with context per CS-006 (unbound-force#9)
- Filed follow-up issue unbound-force#219 for multi-package mixed BDD+normal
  scenario test (unbound-force#4)
jflowers added a commit to jflowers/gaze that referenced this pull request Aug 13, 2026
…nbound-force#4, unbound-force#7)

- Align quality zero-result error message to match gaze crap pattern:
  'no test-target pairs resolved — cannot evaluate thresholds' (unbound-force#7)
- Add TestMergeSummaries_SkippedTestsDivergence to exercise defensive
  guard when SkippedTests > len(SkippedTestNames) (unbound-force#3)
- Add TestMergeSummaries_MultiPackage_AggregatesSkipped for
  mergeSummaries aggregation coverage
- Add TestRunQuality_MixedBDDAndNormalPackages for mixed BDD + normal
  multi-package scenario (unbound-force#4)
- Update 3 existing test assertions for new error message wording
jflowers added a commit that referenced this pull request Aug 13, 2026
- Fix skipped test data missing from report pipeline quality JSON:
  BuildPackageSummary only aggregates report-level data, so
  SkippedTests/SkippedTestNames are now set post-hoc in
  runQualityStep and propagated through ReportSummary (#2, #5)
- Add combined threshold test for --min-contract-coverage +
  --max-over-specification both set on empty results (#1)
- Add divergence edge case test: SkippedTests > len(SkippedTestNames)
  verifies defensive guard prevents out-of-bounds (#3)
- Extract shared MaxSkippedTestDisplay constant from quality package,
  replacing duplicate magic 20 in main.go and report.go (#6)
- Move totalTestFuncs computation inside text format branch where
  it is actually used (#8)
- Wrap WriteJSON/WriteText errors with context per CS-006 (#9)
- Filed follow-up issue #219 for multi-package mixed BDD+normal
  scenario test (#4)
jflowers added a commit that referenced this pull request Aug 13, 2026
- Align quality zero-result error message to match gaze crap pattern:
  'no test-target pairs resolved — cannot evaluate thresholds' (#7)
- Add TestMergeSummaries_SkippedTestsDivergence to exercise defensive
  guard when SkippedTests > len(SkippedTestNames) (#3)
- Add TestMergeSummaries_MultiPackage_AggregatesSkipped for
  mergeSummaries aggregation coverage
- Add TestRunQuality_MixedBDDAndNormalPackages for mixed BDD + normal
  multi-package scenario (#4)
- Update 3 existing test assertions for new error message wording
em-redhat pushed a commit to em-redhat/gaze that referenced this pull request Sep 1, 2026
- Fix skipped test data missing from report pipeline quality JSON:
  BuildPackageSummary only aggregates report-level data, so
  SkippedTests/SkippedTestNames are now set post-hoc in
  runQualityStep and propagated through ReportSummary (unbound-force#2, unbound-force#5)
- Add combined threshold test for --min-contract-coverage +
  --max-over-specification both set on empty results (unbound-force#1)
- Add divergence edge case test: SkippedTests > len(SkippedTestNames)
  verifies defensive guard prevents out-of-bounds (unbound-force#3)
- Extract shared MaxSkippedTestDisplay constant from quality package,
  replacing duplicate magic 20 in main.go and report.go (unbound-force#6)
- Move totalTestFuncs computation inside text format branch where
  it is actually used (unbound-force#8)
- Wrap WriteJSON/WriteText errors with context per CS-006 (unbound-force#9)
- Filed follow-up issue unbound-force#219 for multi-package mixed BDD+normal
  scenario test (unbound-force#4)
em-redhat pushed a commit to em-redhat/gaze that referenced this pull request Sep 1, 2026
…nbound-force#4, unbound-force#7)

- Align quality zero-result error message to match gaze crap pattern:
  'no test-target pairs resolved — cannot evaluate thresholds' (unbound-force#7)
- Add TestMergeSummaries_SkippedTestsDivergence to exercise defensive
  guard when SkippedTests > len(SkippedTestNames) (unbound-force#3)
- Add TestMergeSummaries_MultiPackage_AggregatesSkipped for
  mergeSummaries aggregation coverage
- Add TestRunQuality_MixedBDDAndNormalPackages for mixed BDD + normal
  multi-package scenario (unbound-force#4)
- Update 3 existing test assertions for new error message wording
jflowers added a commit to jflowers/gaze that referenced this pull request Oct 2, 2026
Wire the Go cognitive complexity provider in the crap Go path, add the
--max-cognitive-complexity flag to gaze analyze with exit-code gating,
and surface the cognitive gate in printCISummary.

Addresses PR unbound-force#294 review feedback from @jflowers (findings unbound-force#3 and unbound-force#4).

Signed-off-by: Jay Flowers <[email protected]>
Assisted-by: deepseek-v4-pro
jflowers added a commit that referenced this pull request Oct 2, 2026
Wire the Go cognitive complexity provider in the crap Go path, add the
--max-cognitive-complexity flag to gaze analyze with exit-code gating,
and surface the cognitive gate in printCISummary.

Addresses PR #294 review feedback from @jflowers (findings #3 and #4).

Signed-off-by: Jay Flowers <[email protected]>
Assisted-by: deepseek-v4-pro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant