Skip to content

ci: enforce cyclomatic complexity for Solidity, Go, and Rust - #1124

Draft
srdtrk wants to merge 1 commit into
mainfrom
serdar/cyclomatic-complexity-lint
Draft

srdtrk wants to merge 1 commit into
mainfrom
serdar/cyclomatic-complexity-lint

Conversation

@srdtrk

@srdtrk srdtrk commented Sep 11, 2026

Copy link
Copy Markdown
Member

Summary

Adds cyclomatic complexity enforcement across all three languages in the repo, run in CI and from the language lint recipes.

  • Solidity: keeps the existing Solhint code-complexity limit of 8, now exposed as just solidity::lint-solhint.
  • Go: gocyclo with a maximum of 30. The two e2e/interchaintestv8/solana/test_helpers.go helpers already above that are capped at their current scores in scripts/complexity-limits.json, with reasons.
  • Rust: Mozilla's rust-code-analysis-cli with a maximum of 30, covering SP1, CosmWasm, and Solana workspaces. Nested functions and closures are measured on their own rather than summed into the parent.

scripts/check-complexity.py discovers source files via git ls-files (tracked plus new untracked, honouring ignores) and skips generated headers, vendor/generated/target/out directories, and symlinks. Exceptions are kept honest: a score that drops below its cap, or a function that disappears, fails the check until the exception is lowered or removed.

A new source-only nix develop .#complexity shell runs the checks without compiling any project code or downloading Go/Cargo dependencies. just lint-go and just lint-rust also call the complexity checks, and the analyzers are added to the default shell.

Verification

Run inside nix develop .#complexity:

Check Result
just test-complexity 10 tests pass
just lint-complexity-go 773 functions in 97 files, 0 violations
just lint-complexity-rust 4385 functions in 464 files, 0 violations
just solidity::lint-solhint clean
scripts/check-license-headers.sh clean

🤖 Generated with Claude Code

https://claude.ai/code/session_014acn7oFvabzFDqyfnnhHRV

Solidity keeps the existing Solhint code-complexity limit of 8. Go uses
gocyclo and Rust uses rust-code-analysis-cli, both capped at 30 via
scripts/complexity-limits.json with explicit exceptions for the two Go
test helpers that already exceed it. A source-only `complexity` dev shell
and workflow run the checks without building any project code, and the
language lint recipes call them as well.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014acn7oFvabzFDqyfnnhHRV
Signed-off-by: srdtrk <srdtrk@hotmail.com>
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