Skip to content

chore: add code complexity checks to CI - #561

Merged
GitGuru7 merged 8 commits into
developfrom
feat/code-complexity-gates
Sep 23, 2026
Merged

GitGuru7 merged 8 commits into
developfrom
feat/code-complexity-gates

Conversation

@GitGuru7

@GitGuru7 GitGuru7 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Makes the TypeScript complexity gates stricter and adds a local formatting helper.

What changed

  • Bumped ESLint 7 → 8 (^8.25.0), plus eslint-plugin-promise → ^6.1.1 whose peer range was ESLint 7 only. This is a prerequisite: eslint-plugin-sonarjs@1.0.4 cannot run on ESLint 7.
  • ESLint: complexity and sonarjs/cognitive-complexity now error at 15
  • Added eslint-plugin-sonarjs (^1.0.4)
  • Added a prettier:cached script for local use — CI's prettier:check is unchanged

.solhint.json was left alone — code-complexity is already 15.

Suppressed

One test helper, left with an ignore comment:

  • deployVTokenDependencies in tests/hardhat/util/TokenTestHelpers.ts — complexity 21, cognitive complexity 20

Refactored

  • deploy/009-deploy-vtokens.ts — the three-way interest-rate-model chain moved into deployInterestRateModel, and the ProtocolShareReserve try/catch into resolveProtocolShareReserve. Order of operations, arguments and throws are unchanged.
  • getConfig in helpers/deploymentConfig.ts (complexity 19) — an 18-case switch became a keyed lookup.

Verified

The ESLint 8 bump produced no new findings on its own — same warning count as before. yarn lint:ts and yarn lint:sol both pass with no errors.

@GitGuru7
GitGuru7 marked this pull request as ready for review September 21, 2026 12:19
@GitGuru7 GitGuru7 self-assigned this Sep 21, 2026
@greptile-apps

greptile-apps Bot commented Sep 21, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with the deployment refactors preserving existing behavior and the updated lint dependencies remaining compatible.

Summary

This PR introduces TypeScript complexity gates, updates the ESLint toolchain required by SonarJS, adds a cached local formatting command, and refactors deployment/configuration code to satisfy the new limits.

  • Enforces cyclomatic and cognitive complexity limits of 15.
  • Preserves existing VToken interest-model and ProtocolShareReserve deployment behavior through helper extraction.
  • Replaces the network configuration switch with an equivalent keyed lookup and retains the development alias.
  • Adds a targeted suppression for a pre-existing complex test helper.

Reviews (1) · Last reviewed commit: "refactor: replace getConfig network swit..."

promise, import, node and prettier were never listed in .eslintrc plugins
or extended, so none of their rules ran. Prettier still runs via its own
CLI and eslint-config-prettier stays.
@GitGuru7
GitGuru7 force-pushed the feat/code-complexity-gates branch from a86990d to ff66bbe Compare September 22, 2026 08:04
@github-actions

Copy link
Copy Markdown

Code Coverage

Package Line Rate Branch Rate Health
contracts 83% 72% ✔
contracts.Gateway 98% 68% ✔
contracts.Gateway.Interfaces 100% 100% ✔
contracts.Lens 95% 69% ✔
contracts.Lens.legacy 0% 0% ❌
contracts.Pool 100% 92% ✔
contracts.Rewards 96% 70% ✔
contracts.Shortfall 100% 85% ✔
contracts.legacy.RiskFund 0% 0% ❌
contracts.lib 100% 89% ✔
Summary 72% (1569 / 2190) 63% (520 / 828) ➖

@GitGuru7
GitGuru7 merged commit 32c5ef8 into develop Sep 23, 2026
4 checks passed
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.

3 participants