Skip to content

[jsweep] Clean add_reviewer.cjs#21330

Merged
pelikhan merged 3 commits intomainfrom
jsweep/clean-add-reviewer-24a4906c3a3bdfad
Mar 17, 2026
Merged

[jsweep] Clean add_reviewer.cjs#21330
pelikhan merged 3 commits intomainfrom
jsweep/clean-add-reviewer-24a4906c3a3bdfad

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Mar 17, 2026

Summary

Cleaned add_reviewer.cjs as part of the daily jsweep unbloat process.

Context: github-script (uses core, github, context globals)


Changes

Source: add_reviewer.cjs

  • Removed unused HANDLER_TYPE constant — declared as const HANDLER_TYPE = "add_reviewer" but never referenced anywhere in the file or exported. Pure dead code.

Tests: add_reviewer.test.cjs

  • Added 8 new edge case tests (12 → 20 tests total):
    1. "should handle undefined reviewers as empty array" — verifies the message.reviewers || [] fallback when reviewers is omitted from the message
    2. "should add only copilot when copilot is the only reviewer" — verifies the code path where otherReviewers.length === 0 (first API call is skipped, only copilot API call is made)
    3. "should use default config values when no options provided" — verifies that main({}) uses defaults (all reviewers allowed, max=10)
    4. "should return error for invalid pull_request_number" — verifies NaN handling when pull_request_number is a non-numeric string, null, or alphanumeric value
    5. "should filter out copilot when not in allowed list" — verifies copilot is removed by processItems when not present in the allowed list
    6. "should sanitize null and falsy values in reviewers array" — verifies sanitizeItems strips null/undefined/false/empty-string/whitespace-only entries and trims names
    7. "should trim reviewer list to maxCount within a single message" — verifies processItems hard-limits the reviewer count per call
    8. "should count staged calls toward max processedCount" — verifies processedCount++ fires before the staged-mode early return, consuming the max budget

Validation ✅

All four checks passed:

  • Formatting: npm run format:cjs
  • Linting: npm run lint:cjs
  • Type checking: npm run typecheck
  • Tests: npm run test:js ✓ — 20/20 add_reviewer tests pass (19 pre-existing failures in unrelated files)

Generated by jsweep - JavaScript Unbloater ·

[!WARNING]

  • expires on Mar 19, 2026, 3:25 AM UTC

📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

- Remove unused HANDLER_TYPE constant (dead code)
- Add 3 edge case tests: undefined reviewers, copilot-only reviewer, default config

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review March 17, 2026 03:29
Copilot AI review requested due to automatic review settings March 17, 2026 03:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes dead code from the add_reviewer safe-output handler and strengthens its test suite with additional edge-case coverage.

Changes:

  • Removed unused HANDLER_TYPE constant from actions/setup/js/add_reviewer.cjs.
  • Added 3 edge-case tests for undefined reviewers, copilot-only reviewer behavior, and default config behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
actions/setup/js/add_reviewer.cjs Removes an unused constant to reduce dead code.
actions/setup/js/add_reviewer.test.cjs Adds tests to cover omitted reviewers, copilot-only path, and default handler config behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@pelikhan
Copy link
Contributor

@copilot add tests

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor

Copilot AI commented Mar 17, 2026

@copilot add tests

Added 5 more edge case tests in 0785686 (15 → 20 total):

  1. invalid pull_request_number — non-numeric string causes parseIntNaN, returns error
  2. copilot filtered by allowed list — when "copilot" is not in allowed, processItems removes it before the copilot-special-handling branch ever runs
  3. null/falsy values in reviewerssanitizeItems strips null, undefined, false, "", and trims whitespace
  4. reviewer list capped by maxCount per messageprocessItems limits to the first N reviewers when the list exceeds max
  5. staged calls count toward processedCountprocessedCount++ fires before the staged-mode early return, so staged calls consume the max budget

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan March 17, 2026 03:44
@pelikhan pelikhan merged commit 2bb5b93 into main Mar 17, 2026
80 checks passed
@pelikhan pelikhan deleted the jsweep/clean-add-reviewer-24a4906c3a3bdfad branch March 17, 2026 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants