Skip to content

feat(pipeline): parallel complexity audit step with quality gates#1439

Draft
nextlevelshit wants to merge 2 commits into
mainfrom
1041-complexity-audit-step
Draft

feat(pipeline): parallel complexity audit step with quality gates#1439
nextlevelshit wants to merge 2 commits into
mainfrom
1041-complexity-audit-step

Conversation

@nextlevelshit
Copy link
Copy Markdown
Collaborator

Summary

  • New `audit-complexity` pipeline step computes per-function cyclomatic + cognitive complexity over Go source via in-tree `go/ast` analyzer.
  • Configurable thresholds (default cyclomatic 15, cognitive 15) gate the pipeline; non-zero exit when any function breaches.
  • Parallel execution via `errgroup` + `SetLimit(NumCPU)`, designed to run concurrently with other independent steps.
  • Structured Wave-typed JSON output (shared findings schema) consumable by downstream review/triage steps.
  • New `audit-complexity` pipeline manifest plus integration into `ops-parallel-audit`.

Related to #1041

Changes

  • `internal/complexity/` — analyzer, cyclomatic + cognitive scorers, findings emitter, tests + fixtures.
  • `cmd/wave/commands/audit_complexity.go` (+ test) — CLI subcommand wiring, threshold flags, exit-code gate.
  • `internal/defaults/pipelines/audit-complexity.yaml` — new pipeline.
  • `internal/defaults/pipelines/ops-parallel-audit.yaml` — parallel inclusion.
  • `internal/defaults/contracts/shared-findings.schema.json` + `.agents/contracts/` — schema tweak for complexity findings.
  • `docs/reference/cli.md` — `wave audit complexity` reference.
  • `specs/1041-complexity-audit-step/` — spec, plan, tasks.

Test Plan

  • `go test ./internal/complexity/... ./cmd/wave/commands/...` — unit coverage of analyzer, cyclomatic + cognitive scorers, findings emitter, and CLI flags / exit codes.
  • Edge cases covered: empty file list, non-Go files skipped, broken-syntax fixture, default-threshold behavior, breach diagnostic message naming function + score.
  • Pipeline contract validated against `shared-findings.schema.json`.

…#1041)

Adds an in-tree Go AST analyzer that scores functions by cyclomatic and
cognitive complexity, exposed via `wave audit complexity` and a new
`audit-complexity` pipeline. The pipeline plugs into `ops-parallel-audit`'s
iterate fan-out alongside the LLM-driven audits, gating on per-function
threshold breaches via shared-findings JSON.

- internal/complexity: errgroup-parallel scorer, cyclomatic + cognitive
  visitors, golden-fixture tests, schema-validated findings emitter
- cmd/wave/commands: `wave audit complexity` subcommand with thresholds,
  exclude globs, json/summary formats, exit codes 0/1/2
- internal/defaults/pipelines: audit-complexity.yaml command-step pipeline
  with json_schema gate; ops-parallel-audit fans out 4-wide
- shared-findings schema: adds "complexity" to the type enum
- docs/reference/cli.md: documents the new subcommand
@nextlevelshit nextlevelshit marked this pull request as draft April 27, 2026 19:35
walkExpr never read the nesting argument — it just threaded the
value through to recursive calls. golangci-lint (unparam) flagged
this as a real signal: the parameter cannot affect output.

Drop it. Callers now invoke walkExpr(e) directly. Behaviour
unchanged; the parameter was dead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant