feat: implement issue #442 — SonarCloud modernization (1/3): src/ app code - #446
feat: implement issue #442 — SonarCloud modernization (1/3): src/ app code#446don-petry wants to merge 1 commit into
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
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: 57 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 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 |
|
Dev-Lead — review-changes (no-changes)No changes were needed for this PR. |
CI Failure: SonarCloud Code AnalysisStep: SonarCloud Scan (Quality Gate evaluation) The Quality Gate failed on "0.0% Coverage on New Code (required ≥ 80%)". This is not a real coverage regression from this PR — the Suggested fix: In |
There was a problem hiding this comment.
Pull request overview
This PR implements the first slice of Issue #442 (“SonarCloud modernization 1/3”) by applying behavior-preserving idiom updates across core src/ app code (plus a small supporting test tweak), intended to satisfy SonarCloud recommendations without changing .gs Apps Script files.
Changes:
- Modernize several JS idioms (e.g.,
Date.now(),||defaults, optional chaining, nullish coalescing, regex char-class simplifications). - Update shared Node-side utilities (
src/gas-utils.js) withnode:builtins,replaceAll, and stricter error typing. - Adjust a Jest test’s
Datemocking to support the newDate.now()usage.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/gmail-to-drive-by-labels/tests/code.test.js | Updates Date mocking to cover new Date.now() timing logic. |
| src/gmail-to-drive-by-labels/src/index.js | Applies idiom modernizations (sorting, defaults, regex simplification, Date.now() timing). |
| src/gas-utils.js | Modernizes Node utility usage (node:crypto, regex tweaks, replaceAll, TypeError). |
| src/deploy/index.js | Uses nullish coalescing for explicit null fallback. |
| src/calendar-to-sheets/src/index.js | Small regex char-class tweak and sorting modernization in row deletion flow. |
| src/calendar-to-briefing-doc/src/index.js | Uses optional chaining and nullish coalescing for clearer defaults. |
Comments suppressed due to low confidence (1)
src/gmail-to-drive-by-labels/src/index.js:315
Array.prototype.toSorted()is ES2023. If this extracted logic runs under GAS V8 (or any environment targeting ES2022 per project context), this may not exist and will throw. Prefer the existingslice().sort(...)pattern for compatibility.
function sortThreadsByLastMessageDate(threads) {
return threads.toSorted(function (a, b) {
const aMessages = a.getMessages()
const bMessages = b.getMessages()
const aLastDate = aMessages[aMessages.length - 1].getDate().getTime()
const bLastDate = bMessages[bMessages.length - 1].getDate().getTime()
return aLastDate - bLastDate // Ascending order (oldest first)
})
| const headerPatterns = [ | ||
| /^\s*On\s+.+\s+wrote:/m, | ||
| /^\s*From:\s+.+\s+Sent:\s+/m, | ||
| /^\s*On\s.+\swrote:/m, | ||
| /^\s*From:\s.+\sSent:\s+/m, | ||
| /^\s*_{10,}/m, | ||
| /^\s*From:\s+.+<.+@.+>/m, | ||
| /^\s*From:\s.+<[^\n>]+@[^\n>]+>/m, |
| // Sort messages by date (oldest first) so when we prepend (insert at index 0), | ||
| // the newest messages end up at the top of the document | ||
| const sortedMessages = messages.slice().sort(function (a, b) { | ||
| const sortedMessages = messages.toSorted(function (a, b) { |
| // delete from bottom to top | ||
| console.log('[syncCalendarToSheet] Deleting rows:', toDelete.length) | ||
| toDelete.sort((a, b) => b - a).forEach((r) => sheet.deleteRow(r)) | ||
| toDelete.toSorted((a, b) => b - a).forEach((r) => sheet.deleteRow(r)) |
| // Mock Date to simulate timeout | ||
| const originalDate = Date | ||
| let callCount = 0 | ||
| const elapsedStub = () => { | ||
| callCount++ | ||
| if (callCount > 50) { | ||
| return 5 * 60 * 1000 // 5 minutes - exceeds threshold | ||
| } | ||
| return 0 | ||
| } | ||
| global.Date = class extends originalDate { | ||
| static now() { | ||
| return elapsedStub() | ||
| } | ||
| getTime() { | ||
| callCount++ | ||
| if (callCount > 50) { | ||
| return 5 * 60 * 1000 // 5 minutes - exceeds threshold | ||
| } | ||
| return 0 | ||
| return elapsedStub() | ||
| } | ||
| } | ||
|
|
|
Closing as part of the 50-PR cap drain. The dev-lead fix-loop repairs #1340 (self-cancellation), #1290 (comment-inertness) and #806 (thread-resolution) have all landed, so this deadlocked PR can be regenerated cleanly through the repaired loop. The driving issue stays open and its dev-lead label is re-fired — no work is lost. |
Pull request was closed


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