refactor: Consolidate duplicate directory scanning in LoadFeatures and LoadTransfers#104
Merged
refactor: Consolidate duplicate directory scanning in LoadFeatures and LoadTransfers#104
Conversation
…Files Extract shared directory scanning logic from LoadFeatures and LoadTransfers into a single collectConfigFiles helper that returns a name -> filepath map. Both functions had nearly identical loops for iterating search paths, reading directories, filtering by suffix, and deduplicating by name. This ensures any future bug fixes to the scanning logic only need to be made once. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
bsherman
approved these changes
Mar 30, 2026
bsherman
requested changes
Mar 30, 2026
| transferFiles[component] = filepath.Join(dir, entry.Name()) | ||
| } | ||
| } | ||
| transferFiles, err := collectConfigFiles(searchPaths, ".transfer") |
Contributor
There was a problem hiding this comment.
use const transferSuffix = ".transfer" to match the pattern of featureSuffix in changed file above.
Addresses PR review feedback to use a named constant instead of a string literal for the ".transfer" suffix, consistent with how featureSuffix is defined in feature.go. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Author
|
— Automated by Yeti — Addressed the review comment: added |
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
Extracts the duplicated directory scanning logic from
LoadFeaturesandLoadTransfersinto a sharedcollectConfigFileshelper inconfig/config.go. Both functions performed identical work—scanning search paths for files with a given suffix and building a name-to-filepath map with first-occurrence priority. This reduces duplication and provides a single place to maintain this logic.Changes
config/config.gowith acollectConfigFiles(searchPaths, suffix)helper that scans directories for files matching a suffix and returns a deduplicated name→path mapLoadFeatures(config/feature.go) with a call tocollectConfigFilesLoadTransfers(config/transfer.go) with a call tocollectConfigFilesfeatureSuffixandtransferSuffixconstants for the.featureand.transferfile extensions