[jsweep] Clean campaign_discovery.cjs#11518
Merged
Conversation
This was referenced Jan 23, 2026
Contributor
|
@copilot format, lint, add tests |
Contributor
pelikhan
approved these changes
Jan 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cleaned
campaign_discovery.cjsby extracting duplicate pagination logic into a reusable helper function and modernizing the code with ES6+ patterns.Context
Execution context: github-script (uses
core.info(),core.warning(),githubAPI)Lines changed: 570 → 463 lines (107 lines saved, 18.8% reduction)
Key Improvements
Code Deduplication
searchItemshelper function: Eliminated 120+ lines of duplicate pagination logic betweensearchByTrackerIdandsearchByLabelModernization
buildScopePartsusing spread operator and optional chaining (repos?.length).catch()chaining for cleaner error handlingopenItems,closedItems,mergedItemsonce and reusing||instead of nested if)Function Improvements
buildScopeParts: 10 lines → 5 lines (spread operator, optional chaining)searchByTrackerId: 79 lines → 17 lines (usessearchItemshelper)searchByLabel: 79 lines → 17 lines (usessearchItemshelper)discover: Multiple optimizations including cached filter resultsTest Coverage
✅ All 17 test cases pass (100% success rate)
Tests cover:
Validation Results
✅ All checks passed:
npm run format:cjs✓npm run lint:cjs✓npm run typecheck✓npm run test:js✓ (17/17 tests passed)File Changes
actions/setup/js/campaign_discovery.cjs: Main implementationactions/setup/js/campaign_discovery.test.cjs: Updated imports to include new exportsLabels
unbloat,automation