Refactor: Extract helpers to eliminate duplication (89 lines)#47
Merged
Conversation
- Add parseHeaderInt helper to simplify header parsing - Add updateProgressStatus helper to consolidate rate limit/status updates - Add error handling helpers (logErrorAndReturn, handleFatalError, etc.) - Refactor PopulateSearchTable to use indexTable helper - Simplify updateRateLimitInfo using parseHeaderInt - Replace 60+ lines of duplicated error handling with helpers - Reduced code from 5782 to 5713 lines (69 line reduction) Co-authored-by: wham <448809+wham@users.noreply.github.com>
- Move duplicate gradient color definitions to global variable - Reduced duplication in newModel and newLoginModel - Removed 16 lines of duplicate color definitions - Further reduced from 5713 to 5704 lines Co-authored-by: wham <448809+wham@users.noreply.github.com>
- Replace switch statements with map lookups for item flags - Consolidate ClearData function logic using map and shared loop - More concise and maintainable item processing - Reduced from 5704 to 5684 lines (20 line reduction) - Total reduction: 98 lines from original 5782 Co-authored-by: wham <448809+wham@users.noreply.github.com>
- Fix indentation of updateProgressStatus calls and comments - Separate misplaced comment onto correct line - Address all code review feedback - Code still builds successfully Co-authored-by: wham <448809+wham@users.noreply.github.com>
- Add new helper function for cases where errors are already logged
- Replace handleFatalError("") with exitAfterDelay for clearer intent
- Improves code readability and addresses code review feedback
- Line count: 5693 (still 89 lines reduction from original 5782)
Co-authored-by: wham <448809+wham@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor code to remove duplication and enhance conciseness
Refactor: Extract helpers to eliminate duplication (89 lines)
Dec 20, 2025
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.
Extracted repeated patterns into focused helper functions to reduce duplication across error handling, HTTP header parsing, and UI updates.
Changes
Helper functions (7 added)
parseHeaderInt- Consolidates header→int conversion (4 call sites)updateProgressStatus- Unifies rate limit + API status updates (8 call sites)logErrorAndReturn,exitAfterDelay,handleFatalError,handlePullItemError,checkPreviousFailuresSimplified logic
updateRateLimitInfo: Replaced 4 if-blocks withparseHeaderIntcallsPopulateSearchTable: Extracted 3 identical index operations intoindexTableclosureClearData: Switch statement → map lookup, unified deletion loopExample - Before/After error handling:
5782 → 5693 lines. No functional changes.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.