feat: implement issue #427 — SonarCloud: cognitive complexity (S3776)#431
feat: implement issue #427 — SonarCloud: cognitive complexity (S3776)#431don-petry wants to merge 3 commits into
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reached
Next review available in: 42 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 refactors multiple components by extracting inline logic into modular helper functions. In deploy/index.html, project resolution and error HTML building are extracted. In src/calendar-to-sheets/src/index.js, row upserting, insertion, and deletion computation are modularized. In src/gmail-to-drive-by-labels/src/index.js, duplicate attachment checks, file name resolution, and document rebuilding phases are extracted into separate helpers. The review feedback highlights two key improvement opportunities: optimizing moveEmailsPhase by avoiding redundant and expensive Google Apps Script API calls to processedLabel.getThreads() and replacing array mutations with simple index tracking, and safely handling null or undefined error objects in buildDeployErrorHtml to prevent potential runtime TypeError crashes.
CI Failure: SonarCloud Code AnalysisStep: Quality Gate (New Code Coverage) The SonarCloud Quality Gate failed because New Code Coverage is 0.0%, below the required 80% threshold. This PR (branch Suggested fix: Add unit tests covering the new/changed logic in |
There was a problem hiding this comment.
Pull request overview
Refactors several high-complexity routines flagged by SonarCloud (S3776) into smaller helper functions, aiming to reduce cognitive complexity while preserving existing behavior across Apps Script logic and the deploy UI.
Changes:
gmail-to-drive-by-labels: extracted attachment dedupe + name-conflict logic into helpers; extracted rebuild state machine phases into helpers.calendar-to-sheets: extracted upsert/insert/delete decision logic into helpers to simplifysyncCalendarToSheet.deploy/index.html: extracted idempotent project resolution and deployment error rendering into helper functions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/gmail-to-drive-by-labels/src/index.js | Reduces cognitive complexity by extracting attachment handling and rebuild phases into helpers. |
| src/calendar-to-sheets/src/index.js | Reduces cognitive complexity by extracting row upsert/insert/delete computations into helpers. |
| deploy/index.html | Reduces cognitive complexity by extracting project-id resolution and deploy-error HTML generation into helpers. |
Dev-Lead — fix-reviews (applied)Changes committed and pushed. |
CI Failure: SonarCloud Code AnalysisStep: Quality Gate SonarCloud's Quality Gate failed because New Code coverage is 0.0%, well below the required 80% threshold. The PR extracts several new functions with no accompanying tests: Suggested fix: Add unit tests for the six newly extracted functions listed above (e.g. |
Dev-Lead — review-changes (applied)Changes committed and pushed. |
|
CI Failure: SonarCloud Code AnalysisStep: Quality Gate — The SonarCloud Quality Gate failed because coverage on new code is 0.0%, versus the required minimum of 80% (115 new lines added, all 115 uncovered). This PR (issue #427) extracts two new functions in Suggested fix: Add unit tests for |
Dev-Lead — review-changes (no-changes)No changes were needed for this PR. |


Closes #427
Implemented by dev-lead agent. Please review.