Repository navigation
Enforce dual complexity ceilings (cyclomatic + cognitive ≤16) and decompose pm next renderer - #523
Conversation
…kdown renderer CodeFactor's Complex Method detector is nesting-weighted: GH-518 flagged renderNextMarkdown at cyclomatic 14 (cognitive 22) while flat cyclomatic-16 functions pass, so the old complexity-max-17 cyclomatic gate was structurally blind to the class. Enforce the no-function-over-16 policy on BOTH metrics: complexity max 16 + sonarjs/cognitive-complexity max 16, wired into the same bulk-suppressions ratchet (76 pre-existing violations grandfathered, budget re-pinned 104 -> 180, burn-down tracked as pm-j8vq under pm-92if). Decompose renderNextMarkdown (the live CodeFactor finding, pm-2gvp) into summary/recommended/section/blocked-line helpers with byte-identical output; cognitive drops 22 -> ~5. Extend lint:complexity:baseline to both rules and document the twin ceilings in CONTRIBUTING.md. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VGcEVUn53YH2gwpLpUdvEJ
Reviewer's GuideEnforces dual complexity ceilings (cyclomatic and cognitive ≤16) for the lint/quality gates and refactors the pm Flow diagram for refactored pm next rendererflowchart TD
renderNextMarkdown[renderNextMarkdown]
renderNextSummaryLines[renderNextSummaryLines]
renderNextRecommendedRows[renderNextRecommendedRows]
renderNextSection[renderNextSection]
formatNextBlockedLine[formatNextBlockedLine]
formatNextLine[formatNextLine]
renderNextMarkdown --> renderNextSummaryLines
renderNextMarkdown -->|recommended| renderNextRecommendedRows
renderNextMarkdown -->|Recommended section| renderNextSection
renderNextMarkdown -->|Decision_needed section| renderNextSection
renderNextMarkdown -->|Ready section| renderNextSection
renderNextMarkdown -->|Blocked section| renderNextSection
renderNextRecommendedRows --> formatNextLine
formatNextBlockedLine --> formatNextLine
renderNextMarkdown -->|Blocked rows| formatNextBlockedLine
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
@codex review |
|
/gemini review |
|
To use Codex here, create a Codex account and connect to github. |
📝 WalkthroughWalkthroughThe PR adds SonarJS cognitive-complexity enforcement with a second complexity ceiling and updates grandfathered suppressions. It also refactors ChangesESLint complexity gate
Next command markdown rendering
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces twin complexity ceilings of 16 for both cyclomatic complexity and SonarJS cognitive complexity, integrating eslint-plugin-sonarjs and updating the baseline suppressions and static quality gate limits accordingly. Additionally, the renderNextMarkdown function in src/cli/commands/next.ts is refactored into smaller, dedicated helper functions to improve readability and maintainability. A review comment suggests removing a redundant nullish coalescing guard (?? []) on result.decision_needed since the field is typed as non-optional.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Code Review
This pull request introduces twin complexity ceilings of 16 for both cyclomatic complexity and SonarJS cognitive complexity, integrating eslint-plugin-sonarjs and updating the baseline suppressions and static quality gate accordingly. Additionally, the markdown rendering logic in src/cli/commands/next.ts has been refactored into cleaner helper functions. Feedback on the changes suggests removing a redundant nullish coalescing operator (?? []) on result.decision_needed since the field is typed as non-optional and guaranteed to be populated.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Greptile SummaryThis PR adds a stricter maintainability gate and refactors the
Confidence Score: 5/5Safe to merge with minimal risk. The changes are focused on lint configuration, baseline accounting, documentation, and a mechanical renderer decomposition. The SonarJS rule configuration matches the added dependency, and the renderer refactor preserves the original section ordering and empty-state behavior. No files require special attention.
What T-Rex did
Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Dev as Developer/CI
participant ESLint as ESLint flat config
participant SonarJS as eslint-plugin-sonarjs
participant Supp as eslint-suppressions.json
participant Gate as static-quality-gate
Dev->>ESLint: pnpm lint:eslint
ESLint->>ESLint: "check complexity <= 16"
ESLint->>SonarJS: "check cognitive-complexity <= 16"
ESLint->>Supp: apply grandfathered suppressions
Dev->>Gate: pnpm lint:codefactor
Gate->>Supp: count suppression budget
Gate-->>Dev: fail if baseline exceeds 180
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Dev as Developer/CI
participant ESLint as ESLint flat config
participant SonarJS as eslint-plugin-sonarjs
participant Supp as eslint-suppressions.json
participant Gate as static-quality-gate
Dev->>ESLint: pnpm lint:eslint
ESLint->>ESLint: "check complexity <= 16"
ESLint->>SonarJS: "check cognitive-complexity <= 16"
ESLint->>Supp: apply grandfathered suppressions
Dev->>Gate: pnpm lint:codefactor
Gate->>Supp: count suppression budget
Gate-->>Dev: fail if baseline exceeds 180
Reviews (2): Last reviewed commit: "docs(next): document the decision_needed..." | Re-trigger Greptile |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…call site Gemini flagged the `?? []` as redundant against the non-optional type; it is a deliberate tolerance for JSON payloads from builds predating the decision queue, pinned by the empty-state rendering spec. Say so where it lives. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VGcEVUn53YH2gwpLpUdvEJ
|
@sourcery-ai review |
|
/gemini review |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new cognitive complexity linting rule (sonarjs/cognitive-complexity max 16) and lowers the cyclomatic complexity ceiling from 17 to 16 in the ESLint configuration. To accommodate these changes, existing violations are grandfathered into eslint-suppressions.json, the maximum allowed suppressions in the static quality gate are increased to 180, and the renderNextMarkdown function in src/cli/commands/next.ts is refactored into smaller helper functions to reduce its complexity. There are no review comments provided for this pull request, so no further feedback is available.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Summary
Closes the gate gap behind GH-518 (CodeFactor "Complex Method" in
src/cli/commands/next.ts, tracked as pm-2gvp) and fixes the finding itself.Why the old gate missed it
The existing
complexity: max 17rule was calibrated to an assumption that CodeFactor flags at cyclomatic ≥ 18. GH-518 disproved that: the flaggedrenderNextMarkdownscores cyclomatic 14 but cognitive complexity 22 (deeply nested sections), whilerunNextin the same file (cyclomatic 16, cognitive 5 — flat early returns) was never flagged. CodeFactor's detector is nesting-weighted, so a purely cyclomatic gate is structurally blind to this finding class.Changes
complexity: max 16andsonarjs/cognitive-complexity: max 16(policy: no function over 16 on either metric). Calibration evidence documented in the config comment.renderNextMarkdowndecomposed intorenderNextSummaryLines/renderNextRecommendedRows/renderNextSection/formatNextBlockedLine; output byte-identical (all rendering specs unchanged and green); cognitive 22 → ≤3 per function.MAX_ESLINT_SUPPRESSIONSre-pinned 104 → 180 with the rule-addition exception documented (budget remains lower-only otherwise).lint:complexity:baselinenow covers both rules; addseslint-plugin-sonarjs(dev).Verification
pnpm lint(ESLint + jscpd + static quality gate + token budget): green🤖 Generated with Claude Code
https://claude.ai/code/session_01VGcEVUn53YH2gwpLpUdvEJ
Summary by Sourcery
Enforce dual cyclomatic and cognitive complexity ceilings in ESLint and refactor the pm next CLI renderer to comply while keeping output unchanged.
Enhancements:
Build:
Summary by cubic
Enforce dual complexity ceilings (cyclomatic and cognitive ≤16) and refactor the
pm nextmarkdown renderer into small helpers to close the CodeFactor “Complex Method” gap. Addresses GH-518, tracked as pm-2gvp; behavior and output are unchanged.Refactors
complexitymax 16 andsonarjs/cognitive-complexitymax 16; extendlint:complexity:baselineto cover both.renderNextMarkdownintorenderNextSummaryLines/renderNextRecommendedRows/renderNextSection/formatNextBlockedLine; add an inline note explaining thedecision_needed ?? []legacy-payload guard; output remains byte-identical.eslint-suppressions.json; re-pin static gateMAX_ESLINT_SUPPRESSIONSfrom 104 to 180 with rule-addition note; document policy inCONTRIBUTING.md.Dependencies
eslint-plugin-sonarjsfor cognitive complexity rules.Written for commit f4f3d7b. Summary will update on new commits.