Skip to content

feat: implement issue #442 — SonarCloud modernization (1/3): src/ app code - #446

Closed
don-petry wants to merge 1 commit into
mainfrom
dev-lead/issue-442-20260715-0323
Closed

feat: implement issue #442 — SonarCloud modernization (1/3): src/ app code#446
don-petry wants to merge 1 commit into
mainfrom
dev-lead/issue-442-20260715-0323

Conversation

@don-petry

Copy link
Copy Markdown
Collaborator

Closes #442

Implemented by dev-lead agent. Please review.

Copilot AI review requested due to automatic review settings July 15, 2026 03:34
@don-petry
don-petry requested a review from a team as a code owner July 15, 2026 03:34
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@don-petry, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 57 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6fd00b93-3936-4c6a-9485-2b67764c3cc8

📥 Commits

Reviewing files that changed from the base of the PR and between 0fb5caf and 059e91c.

📒 Files selected for processing (6)
  • src/calendar-to-briefing-doc/src/index.js
  • src/calendar-to-sheets/src/index.js
  • src/deploy/index.js
  • src/gas-utils.js
  • src/gmail-to-drive-by-labels/src/index.js
  • src/gmail-to-drive-by-labels/tests/code.test.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev-lead/issue-442-20260715-0323

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.

❤️ Share

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

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry
don-petry enabled auto-merge (squash) July 15, 2026 03:35
@github-actions

Copy link
Copy Markdown
Contributor

CI Failure: SonarCloud Code Analysis

Step: SonarCloud Scan (Quality Gate evaluation)
Root cause: Config error

The Quality Gate failed on "0.0% Coverage on New Code (required ≥ 80%)". This is not a real coverage regression from this PR — the sonarcloud.yml workflow only checks out the repo and runs sonarqube-scan-action; it never runs tests with coverage or points Sonar at a report. sonar-project.properties has no sonar.javascript.lcov.reportPaths set, so Sonar has no coverage data to import and treats all new lines as 0% covered via its Zero Coverage Sensor. This will fail on every PR touching JS/TS code, regardless of test quality, since the "Coverage" workflow (which does run Jest with coverage) runs as a separate job and never shares its lcov.info with the Sonar job.

Suggested fix: In .github/workflows/sonarcloud.yml, add a step before the SonarCloud Scan to install deps and run the existing coverage script (e.g. npm ci && npm run test:coverage), then set sonar.javascript.lcov.reportPaths=coverage/lcov.info in sonar-project.properties so the scan ingests real coverage data.

View run logs

Copilot AI 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.

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) with node: builtins, replaceAll, and stricter error typing.
  • Adjust a Jest test’s Date mocking to support the new Date.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 existing slice().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)
  })

Comment thread src/gas-utils.js
Comment on lines 9 to +13
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))
Comment on lines 168 to 186
// 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()
}
}

@don-petry

Copy link
Copy Markdown
Collaborator Author

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.

@don-petry don-petry closed this Jul 21, 2026
auto-merge was automatically disabled July 21, 2026 19:20

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SonarCloud modernization (1/3): src/ app code

3 participants