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.
🧹 refactor: reduce complexity in download_worker of git-fetch.py #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
🧹 refactor: reduce complexity in download_worker of git-fetch.py #236
Changes from all commits
4f77d32File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
Check warning on line 95 in Cachyos/Scripts/WIP/gh/git-fetch.py
Cachyos/Scripts/WIP/gh/git-fetch.py#L95
Check notice on line 110 in Cachyos/Scripts/WIP/gh/git-fetch.py
Cachyos/Scripts/WIP/gh/git-fetch.py#L110
Check notice on line 114 in Cachyos/Scripts/WIP/gh/git-fetch.py
Cachyos/Scripts/WIP/gh/git-fetch.py#L114
Check notice on line 158 in Cachyos/Scripts/WIP/gh/git-fetch.py
Cachyos/Scripts/WIP/gh/git-fetch.py#L158
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this refactoring is a good step in reducing complexity in
download_worker, the extractedprocess_single_downloadfunction itself has some maintainability issues that could be improved:Magic Number: The timeout value
30is hardcoded in multiple places (here and elsewhere in the file). This should be defined as a module-level constant, e.g.,HTTP_TIMEOUT = 30, for better maintainability.Duplicated Logic (DRY violation): The logic for closing and reopening a connection when
should_closeis true is repeated three times within this function.This could be extracted into a small, private helper function (e.g.,
_reconnect(conn, host)) to reduce code duplication and make the intent clearer.Uh oh!
There was an error while loading. Please reload this page.