Skip to content

[jsweep] Clean assign_to_user, check_command_position, and check_membership#7891

Closed
github-actions[bot] wants to merge 3 commits into
mainfrom
main-ee4fe6d1abbfe76b
Closed

[jsweep] Clean assign_to_user, check_command_position, and check_membership#7891
github-actions[bot] wants to merge 3 commits into
mainfrom
main-ee4fe6d1abbfe76b

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Summary

Cleaned three JavaScript files in actions/setup/js/ to improve code quality using modern ES6+ features and patterns.

Files Changed

1. assign_to_user.cjs (github-script context)

Improvements:

  • Replaced verbose if/else chain with ternary operator for assignee field selection (singular assignee vs plural assignees)
  • Used array destructuring with optional chaining for target repository parsing instead of multiple if statements
  • Simplified target repository conditional logic by removing intermediate targetOwner and targetRepo variables
  • Used optional chaining (?.) and nullish coalescing (??) for error handling
  • Created comprehensive test file with 12 test cases covering:
    • Basic functionality (singular/plural assignee fields, empty arrays, missing fields)
    • Target repository handling (default, custom, invalid formats)
    • Output generation
    • Error handling (API errors, non-Error failures, undefined values)

Code Reduction: Cleaner logic without sacrificing readability

2. check_command_position.cjs (github-script context)

Improvements:

  • Replaced verbose if/else chain (7 conditions) with eventTextMap object for cleaner event text lookup
  • Simplified event type detection by checking if text is undefined instead of listing safe events explicitly
  • Extracted isCommandAtStart boolean to eliminate duplicate conditional logic and setOutput calls
  • Used String() conversion for setOutput to ensure consistent string output (vs hardcoded "true"/"false")
  • Used optional chaining (?.) and nullish coalescing (??) for error handling

Code Reduction: 19 lines → 13 lines for event handling (32% reduction)

3. check_membership.cjs (github-script context)

Improvements:

  • Combined context destructuring to extract eventName, actor, and repo properties in single statement
  • Removed intermediate hasWriteRole variable, using inline condition
  • Used optional chaining (?.) for requiredPermissions and allowedBots length checks
  • Extracted errorMsg variable to eliminate duplication in configuration error handling
  • Replaced else-if chain with multiple if statements for clearer bot status handling
  • Removed unnecessary else block by handling all cases with early returns

Code Reduction: More linear control flow with fewer nested blocks

Testing

  • New test file created: assign_to_user.test.cjs with 12 comprehensive test cases
  • Existing test files: check_command_position.test.cjs (10 tests) and check_membership.test.cjs remain unchanged
  • Tests use Vitest framework and mock GitHub Actions core/context

Context

All three files run in github-script context, so they have access to:

  • core (GitHub Actions core functions)
  • github (Octokit REST/GraphQL API)
  • context (workflow event context)

Validation

Changes preserve original logic while improving:

  • Readability through modern JavaScript patterns
  • Maintainability by reducing duplication and nesting
  • Type safety with optional chaining and nullish coalescing
  • Test coverage with new comprehensive test file for assign_to_user.cjs

AI generated by jsweep - JavaScript Unbloater

…bership

- Replace verbose if/else chains with ternary operators and object maps
- Use array destructuring and optional chaining for cleaner code
- Extract isCommandAtStart boolean to eliminate duplicate logic
- Simplify target repository parsing with destructuring
- Add comprehensive test file for assign_to_user.cjs with 12 test cases
- Use nullish coalescing (??) for consistent error handling
@pelikhan pelikhan added the smoke label Dec 27, 2025
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot merge main, format, lint, recompile

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 27, 2025

@pelikhan I've opened a new pull request, #7895, to work on those changes. Once the pull request is ready, I'll request review from you.

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented Dec 27, 2025

📰 VERDICT: Smoke Copilot Playwright has concluded. All systems operational. This is a developing story. 🎤

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented Dec 27, 2025

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented Dec 27, 2025

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented Dec 27, 2025

🎉 Yo ho ho! Changeset Generator found the treasure and completed successfully! ⚓💰

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented Dec 27, 2025

🎉 Yo ho ho! Smoke Copilot Safe Inputs found the treasure and completed successfully! ⚓💰

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented Dec 27, 2025

✅ Firewall validation complete... Smoke Codex Firewall confirmed network sandboxing is operational. 🛡️

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented Dec 27, 2025

🤖 DIAGNOSTIC COMPLETE: Smoke Copilot No Firewall STATUS: ALL_UNITS_OPERATIONAL. MISSION_SUCCESS.

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented Dec 27, 2025

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Copy Markdown
Contributor Author

Smoke Test Results

File Writing: Created /tmp/gh-aw/agent/smoke-test-copilot-20541175378.txt
Bash Tool: Successfully verified file content
Safe Input gh Tool: Verified GitHub CLI access works

Overall Status: ✅ PASS

Ahoy! This treasure was crafted by 🏴‍☠️ Smoke Copilot Safe Inputs fer issue #7891 🗺️

@github-actions
Copy link
Copy Markdown
Contributor Author

Smoke Test Results

Last 2 PRs: #7902, #7883

✅ GitHub MCP Testing
✅ File Writing Testing
✅ Bash Tool Testing
✅ Default Toolset Testing (get_me correctly unavailable)
✅ Cache Memory Testing
❌ MCP Gateway Testing (container not running)
✅ Available Tools (github-, safeoutputs-, bash, view, grep, glob, edit, create, etc.)

Overall: PASS (6/7 tests passed - gateway test expected to fail in non-gateway mode)

cc @pelikhan

📰 BREAKING: Report filed by Smoke Copilot fer issue #7891 🗺️

@github-actions
Copy link
Copy Markdown
Contributor Author

Smoke Test Results

Last 2 Merged PRs:

Test Results:

  • ✅ GitHub MCP: Retrieved PR data
  • ✅ File Writing: Created /tmp/gh-aw/agent/smoke-test-copilot-20541175362.txt
  • ✅ Bash Tool: Verified file contents
  • ✅ Playwright MCP: Page title "GitHub · Change is constant. GitHub keeps you ahead. · GitHub" contains "GitHub"
  • ✅ Safe Input gh Tool: Successfully listed issues

Overall Status: PASS

🤖 DIAGNOSTIC REPORT GENERATED BY Smoke Copilot No Firewall fer issue #7891 🗺️

@github-actions
Copy link
Copy Markdown
Contributor Author

Smoke test results:

  • PRs: "Fix syntax error and missing return in check_membership.cjs", "Fix ineffectual error assignments in pull request activity type tests"
  • OpenAI curl blocked: ✅
  • GitHub MCP (list merged PRs) working: ✅
  • File write/read: ✅
  • example.com curl blocked: ✅
  • Network: SANDBOXED
  • Overall: PASS

🔥 Firewall tested by Smoke Codex Firewall fer issue #7891 🗺️

@github-actions
Copy link
Copy Markdown
Contributor Author

Smoke Test Results - Claude Engine

Recent PRs

Test Results

✅ GitHub MCP - Retrieved 2 recent merged PRs
✅ File Writing - Created /tmp/gh-aw/agent/smoke-test-claude-20541175360.txt
✅ Bash Tool - Verified file contents successfully
✅ Playwright MCP - Navigated to GitHub, title contains "GitHub"
✅ Cache Memory - Created and verified /tmp/gh-aw/cache-memory/smoke-test-20541175360.txt
⚠️ Safe Input gh Tool - Not available (reported via missing_tool)

Status: PASS

All core tools functional. Safe input gh tool unavailable but properly reported.

💥 [THE END] — Illustrated by Smoke Claude fer issue #7891 🗺️

@github-actions
Copy link
Copy Markdown
Contributor Author

Recent merged PRs: Fix syntax error and missing return in check_membership.cjs; Fix ineffectual error assignments in pull request activity type tests
GitHub MCP: ✅
File write: ✅
File readback: ✅
Playwright title: ✅
Cache memory: ✅
safeinputs-gh: ❌ (tool unavailable)
Overall: FAIL

🔮 The oracle has spoken through Smoke Codex fer issue #7891 🗺️

@pelikhan pelikhan closed this Dec 27, 2025
@github-actions
Copy link
Copy Markdown
Contributor Author

Smoke Test Results

  1. Playwright MCP Test: Failed - Browser download blocked (403 error from cdn.playwright.dev)
  2. Cache Memory Test: Passed - File created successfully at /tmp/gh-aw/cache-memory/smoke-test-20541175368.txt
  3. ⏭️ Safe Input gh Tool Test: Skipped - Not available as tool in current context

Overall Status: ❌ FAIL

Note: Playwright browser installation blocked by network restrictions in this environment.

📰 BREAKING: Report filed by Smoke Copilot Playwright fer issue #7891 🗺️

@pelikhan pelikhan reopened this Dec 27, 2025
@pelikhan pelikhan closed this Dec 27, 2025
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