Skip to content

[jsweep] Clean check_membership.cjs#22831

Merged
pelikhan merged 1 commit intomainfrom
jsweep/check-membership-cleanup-c2314ad73900f5a9
Mar 25, 2026
Merged

[jsweep] Clean check_membership.cjs#22831
pelikhan merged 1 commit intomainfrom
jsweep/check-membership-cleanup-c2314ad73900f5a9

Conversation

@github-actions
Copy link
Contributor

Summary

Cleaned check_membership.cjs — a github-script context file that handles repository membership and permission validation.

Changes

check_membership.cjs — removed redundant null guards:

  • parseRequiredPermissions() always returns string[] (via ?? []), so !requiredPermissions || was a dead check
  • parseAllowedBots() always returns string[] (via ?? []), so allowedBots && was a dead check
-  if (!requiredPermissions || requiredPermissions.length === 0) {
+  if (requiredPermissions.length === 0) {
-    if (allowedBots && allowedBots.length > 0) {
+    if (allowedBots.length > 0) {

Test improvements

check_membership.test.cjs — 24 → 26 tests (+2):

New test Purpose
should skip bot check when GH_AW_ALLOWED_BOTS is empty string Verifies empty string env var yields only 1 API call and no bot check
should skip bot check when GH_AW_ALLOWED_BOTS is not set Verifies unset env var yields only 1 API call and no bot check

Context

  • Execution context: github-script
  • No logic changed — pure code clarity improvements

✅ Validation checks

  • Formatting: npm run format:cjs
  • Linting: npm run lint:cjs
  • Type checking: npm run typecheck
  • Tests: npm run test:js -- --no-file-parallelism ✓ (26/26 passed)

Generated by jsweep - JavaScript Unbloater ·

  • expires on Mar 27, 2026, 4:41 AM UTC

- Remove redundant null guard on parseRequiredPermissions() return value
  (always returns string[], never null/undefined)
- Remove redundant null guard on parseAllowedBots() return value
  (always returns string[], never null/undefined)
- Add 2 new tests: empty and unset GH_AW_ALLOWED_BOTS skip bot check
  (24 → 26 tests)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review March 25, 2026 10:33
Copilot AI review requested due to automatic review settings March 25, 2026 10:33
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

This PR simplifies check_membership.cjs by removing redundant null/undefined guards around values that are guaranteed to be arrays, and adds targeted tests to lock in the expected behavior when the bot allowlist env var is empty or unset.

Changes:

  • Removed dead null checks for requiredPermissions and allowedBots in check_membership.cjs (both parsers always return string[]).
  • Added 2 tests ensuring bot-status API calls are skipped when GH_AW_ALLOWED_BOTS is "" or unset.

Reviewed changes

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

File Description
actions/setup/js/check_membership.cjs Removes redundant guards now that env parsing utilities always return arrays.
actions/setup/js/check_membership.test.cjs Adds regression tests verifying no bot-check API calls when allowlist is empty/unset.

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

@pelikhan pelikhan merged commit 2d6ac60 into main Mar 25, 2026
64 checks passed
@pelikhan pelikhan deleted the jsweep/check-membership-cleanup-c2314ad73900f5a9 branch March 25, 2026 11:04
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.

2 participants