Skip to content

feat(go): Go and TypeScript function metrics in code-shape-gate (RIG-8435) - #69

Open
rigel-mintaka wants to merge 54 commits into
mainfrom
ci-pipelines/rig-8435-go-and-typescript-function-metrics-in
Open

rigel-mintaka wants to merge 54 commits into
mainfrom
ci-pipelines/rig-8435-go-and-typescript-function-metrics-in

Conversation

@rigel-mintaka

@rigel-mintaka rigel-mintaka commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

code-shape-gate now checks function shape as well as file and directory size, for Go and TypeScript.

  • Go: function length, cognitive complexity, and parameters, measured from source.
  • TypeScript: cognitive and cyclomatic complexity from Biome, plus function length and parameters.
  • Forced Biome config: Biome runs with a generated temporary config that sets both complexity rules at the gate's limits. The repo's own Biome config, nested configs, .biomeignore and BIOME_CONFIG_PATH cannot change what is measured. The repo config is checked only for drift, such as a disabled rule.
  • Fails closed:
    • A counted file whose functions go unmeasured is an unmeasured finding, for example a parse error or a file Biome skipped.
    • If Biome processes fewer files than requested, the gate exits 2 and prints the counts.
    • The gate's own exclude is the only opt-out.
  • Allowlist ratchet: allowlisted function entries can only shrink. Preserved entries stay under the base comparison.
  • Path safety: paths go to Biome after --, so a file named like a flag is measured as a file. Files over Biome's default 1 MiB limit are still measured.

The package is split into config, golang, typescript and cli. The README documents the function limits and the unmeasured finding.

Verification

  • moon run :ci --force: Tasks: 40 completed.
  • go test -count=1 ./internal/codeshape/...: all five packages ok, including tests against real Biome 2.5.15.
  • golangci-lint: 0 issues. nix build .#packages.x86_64-linux.tools succeeded.
  • Review: five rounds; the final pass found 0 high, 0 medium. Two lows are left: a Biome-specific field on a shared type, and an optional nested-config test.

Risks

  • Adopting repos may see new findings for long functions or unmeasured files.
  • On a count mismatch the error gives counts, not the skipped file; Biome's JSON doesn't list processed files.

Refs RIG-8435

Co-authored-by: Matt Wilkinson matt@rigel.build

rigel-mintaka and others added 30 commits November 10, 2026 03:52
…8435)

Co-authored-by: Matt Wilkinson <matt@rigel.build>
@linear-code

linear-code Bot commented Nov 10, 2026

Copy link
Copy Markdown

RIG-8435

@rigel-mintaka

Copy link
Copy Markdown
Contributor Author

Review all-clear at 4454688.

  • Final review (range 1202fe2..0f6d95c): 0 high, 0 medium, 4 low.
  • Fixed in 4454688: the count-mismatch error now prints counts, and the fail-closed test checks the error text.
  • Left as is: a Biome-specific field on a shared type, and an optional nested .biome.json test.
  • moon run :ci --force: 40 tasks completed.

@rigel-mintaka

Copy link
Copy Markdown
Contributor Author

All-clear on 44546883e5644ac1b9f935074d1cc356f3e32602 (base main)

@rigel-mintaka
rigel-mintaka marked this pull request as ready for review November 10, 2026 20:03

This branch has not been deployed

No deployments
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