Skip to content

chore(lint): ratchet cognitive complexity - #5419

Merged
cv merged 3 commits into
mainfrom
chore/biome-cognitive-complexity-ratchet
Jun 14, 2026
Merged

chore(lint): ratchet cognitive complexity#5419
cv merged 3 commits into
mainfrom
chore/biome-cognitive-complexity-ratchet

Conversation

@cv

@cv cv commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

Enable Biome's cognitive complexity lint rule as an error at the current maximum observed threshold. This starts the ratchet without requiring refactors or introducing per-file exceptions in the PR.

Changes

  • Added complexity/noExcessiveCognitiveComplexity to biome.json with maxAllowedComplexity: 255.
  • Keeps the current tree passing while preventing future functions from exceeding the existing top score.
  • Avoids scoped overrides or ignore comments so the lint ratchet starts from a single global baseline.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Verification

Targeted validation run before commit:

  • npx @biomejs/biome lint --only=complexity/noExcessiveCognitiveComplexity --max-diagnostics=none .

  • npx @biomejs/biome lint biome.json

  • npx @biomejs/biome format biome.json

  • Git hooks passed during commit and push, or npx prek run --from-ref main --to-ref HEAD passes

  • Targeted tests pass for changed behavior

  • Full npm test passes (broad runtime changes only)

  • Tests added or updated for new or changed behavior

  • No secrets, API keys, or credentials committed

  • Docs updated for user-facing behavior changes

  • npm run docs builds without warnings (doc changes only)

  • Doc pages follow the style guide (doc changes only)

  • New doc pages include SPDX header and frontmatter (new pages only)


Signed-off-by: Carlos Villela cvillela@nvidia.com

Summary by CodeRabbit

  • Chores
    • Updated the linter configuration to enforce stricter cognitive complexity checks, reporting excessive complexity as an error to help keep code easier to maintain.

Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv cv self-assigned this Jun 14, 2026
@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

biome.json gains a new linter rule: complexity.noExcessiveCognitiveComplexity set to error level with maxAllowedComplexity: 255 at the base rules level.

Changes

Biome Linter Cognitive Complexity Rule

Layer / File(s) Summary
Add noExcessiveCognitiveComplexity base rule
biome.json
Adds complexity.noExcessiveCognitiveComplexity at error level with maxAllowedComplexity: 255 to the base linter rules.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

A rabbit counts the winding paths,
where tangled logic breeds its wrath.
Two-fifty-five's the magic score—
keep complexity bounded to the core!
🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore(lint): ratchet cognitive complexity' directly and clearly describes the main change: enabling cognitive complexity linting with a ratcheting approach in biome.json configuration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/biome-cognitive-complexity-ratchet

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-code-quality

github-code-quality Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in the chore/biome-cognitiv... branch is 96%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main chore/biome-cognitiv... 831ed89 +/-
nemoclaw/src/se...cret-scanner.ts 100%
nemoclaw/src/commands/slash.ts 100%
nemoclaw/src/li...bprocess-env.ts 100%
nemoclaw/src/bl...eprint/state.ts 98%
nemoclaw/src/onboard/config.ts 98%
nemoclaw/src/bl...int/snapshot.ts 97%
nemoclaw/src/bl...print/runner.ts 95%
nemoclaw/src/co...ration-state.ts 94%
nemoclaw/src/bl...ate-networks.ts 94%
nemoclaw/src/index.ts 94%

TypeScript / code-coverage/cli

The overall coverage in the chore/biome-cognitiv... branch is 44%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main chore/biome-cognitiv... 831ed89 +/-
src/lib/state/o...oard-session.ts 90%
src/lib/inference/local.ts 77%
src/lib/sandbox/config.ts 72%
src/lib/inference/nim.ts 72%
src/lib/onboard/preflight.ts 64%
src/lib/state/sandbox.ts 55%
src/lib/onboard...er-gpu-patch.ts 50%
src/lib/actions...licy-channel.ts 49%
src/lib/policy/index.ts 48%
src/lib/onboard.ts 17%

Updated June 14, 2026 18:00 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@github-actions

github-actions Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

E2E Advisor Recommendation

Required E2E: None
Optional E2E: None

Workflow run

Full advisor summary

E2E Recommendation Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required E2E

  • None. No E2E is recommended because this PR only changes Biome lint configuration and cannot affect runtime behavior or real user flows.

Optional E2E

  • None.

New E2E recommendations

  • None.

@github-actions

github-actions Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Vitest E2E Scenario Recommendation

Required Vitest E2E scenarios: None
Optional Vitest E2E scenarios: None

Workflow run

Full Vitest E2E advisor summary

Vitest E2E Scenario Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required Vitest E2E scenarios

  • None. Only biome.json lint/format configuration changed, outside test/e2e-scenario/ and the Vitest scenario workflow machinery; this cannot affect Vitest E2E scenario behavior.

Optional Vitest E2E scenarios

  • None.

Relevant changed files

  • None.

@github-actions

github-actions Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor

Findings: 0 needs attention, 0 worth checking, 0 nice ideas
Since last review: 2 prior items resolved, 0 still apply, 0 new items found

Workflow run details

This is an automated advisory review. A human maintainer must make the final merge decision.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@biome.json`:
- Around line 85-92: The maxAllowedComplexity option in the
noExcessiveCognitiveComplexity rule is set to 255, which exceeds Biome's valid
range of 1 to 254. Change the maxAllowedComplexity value from 255 to 254 or any
lower valid integer to comply with Biome's configuration requirements for this
cognitive complexity threshold.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c7a68442-e720-4180-8bb7-da277aa1c3dc

📥 Commits

Reviewing files that changed from the base of the PR and between c95b776 and 005fe1e.

📒 Files selected for processing (1)
  • biome.json

Comment thread biome.json
cv added 2 commits June 14, 2026 10:53
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@biome.json`:
- Around line 99-113: The noExcessiveCognitiveComplexity rule configuration for
the src/lib/onboard.ts override specifies a maxAllowedComplexity value of 255,
which exceeds Biome 2.4.14's documented maximum of 254. Update the
maxAllowedComplexity option value from 255 to 254 to conform to the valid range
of 1–254 inclusive.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 392859fe-04b0-4e85-8a68-2c4f00541076

📥 Commits

Reviewing files that changed from the base of the PR and between 005fe1e and 59afc54.

📒 Files selected for processing (1)
  • biome.json

Comment thread biome.json Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
biome.json (1)

85-92: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Implementation contradicts the PR objectives' stated design.

The PR objectives describe a ratcheting approach with:

  • Global maxAllowedComplexity threshold at 254
  • Scoped override for src/lib/onboard.ts with ceiling of 255

However, the actual implementation shows:

  • Base rule maxAllowedComplexity set to 255 (line 89)
  • No override for src/lib/onboard.ts present in the overrides array

This discrepancy means the configuration does not implement the intended ratcheting design. Either the PR objectives are outdated, or the implementation needs to be corrected to match the design.

🔧 Proposed fix to align with PR objectives
       "complexity": {
         "noExcessiveCognitiveComplexity": {
           "level": "error",
           "options": {
-            "maxAllowedComplexity": 255
+            "maxAllowedComplexity": 254
           }
         }
       },

And add an override block for src/lib/onboard.ts:

   "overrides": [
+    {
+      "includes": ["src/lib/onboard.ts"],
+      "linter": {
+        "rules": {
+          "complexity": {
+            "noExcessiveCognitiveComplexity": {
+              "level": "error",
+              "options": {
+                "maxAllowedComplexity": 254
+              }
+            }
+          }
+        }
+      }
+    },
     {
       "includes": [

Note: The override should also use 254 (not 255) to stay within Biome's valid range.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@biome.json` around lines 85 - 92, The noExcessiveCognitiveComplexity rule
configuration does not match the PR objectives' ratcheting design. Change the
maxAllowedComplexity value from 255 to 254 in the noExcessiveCognitiveComplexity
options block, and add an override entry in the overrides array for the file
path src/lib/onboard.ts that includes its own noExcessiveCognitiveComplexity
configuration with maxAllowedComplexity set to 254 to implement the intended
design.
♻️ Duplicate comments (1)
biome.json (1)

85-92: ⚠️ Potential issue | 🔴 Critical

The maxAllowedComplexity value of 255 exceeds Biome's maximum.

This issue was already flagged in previous reviews: Biome 2.4.14 enforces a valid range of 1–254 for maxAllowedComplexity. The configured value of 255 will be rejected by the linter.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@biome.json` around lines 85 - 92, The maxAllowedComplexity option in the
noExcessiveCognitiveComplexity rule within biome.json is set to 255, which
exceeds Biome's valid range of 1–254. Change the value from 255 to a valid
number within the acceptable range, such as 254 or any lower value that meets
your project's complexity requirements.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@biome.json`:
- Around line 85-92: The noExcessiveCognitiveComplexity rule configuration does
not match the PR objectives' ratcheting design. Change the maxAllowedComplexity
value from 255 to 254 in the noExcessiveCognitiveComplexity options block, and
add an override entry in the overrides array for the file path
src/lib/onboard.ts that includes its own noExcessiveCognitiveComplexity
configuration with maxAllowedComplexity set to 254 to implement the intended
design.

---

Duplicate comments:
In `@biome.json`:
- Around line 85-92: The maxAllowedComplexity option in the
noExcessiveCognitiveComplexity rule within biome.json is set to 255, which
exceeds Biome's valid range of 1–254. Change the value from 255 to a valid
number within the acceptable range, such as 254 or any lower value that meets
your project's complexity requirements.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: abf499ce-b83b-4555-8461-ee2dc241eaca

📥 Commits

Reviewing files that changed from the base of the PR and between 59afc54 and 831ed89.

📒 Files selected for processing (1)
  • biome.json

@cv
cv merged commit f4f3c58 into main Jun 14, 2026
45 of 46 checks passed
@cv
cv deleted the chore/biome-cognitive-complexity-ratchet branch June 14, 2026 18:03
@cv cv added the v0.0.65 label Jun 15, 2026
@wscurran wscurran added area: ci CI workflows, checks, release automation, or GitHub Actions chore Build, CI, dependency, or tooling maintenance labels Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci CI workflows, checks, release automation, or GitHub Actions chore Build, CI, dependency, or tooling maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants