chore(lint): ratchet cognitive complexity - #5419
Conversation
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
📝 WalkthroughWalkthrough
ChangesBiome Linter Cognitive Complexity Rule
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Code Coverage OverviewLanguages: TypeScript TypeScript / code-coverage/pluginThe overall coverage in the Show a code coverage summary of the most covered files.
TypeScript / code-coverage/cliThe overall coverage in the Show a code coverage summary of the most covered files.
Updated |
E2E Advisor RecommendationRequired E2E: None Full advisor summaryE2E Recommendation AdvisorBase: Required E2E
Optional E2E
New E2E recommendations
|
Vitest E2E Scenario RecommendationRequired Vitest E2E scenarios: None Full Vitest E2E advisor summaryVitest E2E Scenario AdvisorBase: Required Vitest E2E scenarios
Optional Vitest E2E scenarios
Relevant changed files
|
PR Review AdvisorFindings: 0 needs attention, 0 worth checking, 0 nice ideas This is an automated advisory review. A human maintainer must make the final merge decision. |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
biome.json
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
biome.json
There was a problem hiding this comment.
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 liftImplementation contradicts the PR objectives' stated design.
The PR objectives describe a ratcheting approach with:
- Global
maxAllowedComplexitythreshold at 254- Scoped override for
src/lib/onboard.tswith ceiling of 255However, the actual implementation shows:
- Base rule
maxAllowedComplexityset to 255 (line 89)- No override for
src/lib/onboard.tspresent in theoverridesarrayThis 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 | 🔴 CriticalThe
maxAllowedComplexityvalue 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
📒 Files selected for processing (1)
biome.json
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
complexity/noExcessiveCognitiveComplexitytobiome.jsonwithmaxAllowedComplexity: 255.Type of Change
Verification
Targeted validation run before commit:
npx @biomejs/biome lint --only=complexity/noExcessiveCognitiveComplexity --max-diagnostics=none .npx @biomejs/biome lint biome.jsonnpx @biomejs/biome format biome.jsonGit hooks passed during commit and push, or
npx prek run --from-ref main --to-ref HEADpassesTargeted tests pass for changed behavior
Full
npm testpasses (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 docsbuilds 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