Skip to content

refactor: Consolidate duplicate directory scanning in LoadFeatures and LoadTransfers#104

Merged
bketelsen merged 2 commits intomainfrom
yeti/improve-ef00
Mar 30, 2026
Merged

refactor: Consolidate duplicate directory scanning in LoadFeatures and LoadTransfers#104
bketelsen merged 2 commits intomainfrom
yeti/improve-ef00

Conversation

@frostyardyeti
Copy link
Copy Markdown
Contributor

@frostyardyeti frostyardyeti Bot commented Mar 28, 2026

Summary

Extracts the duplicated directory scanning logic from LoadFeatures and LoadTransfers into a shared collectConfigFiles helper in config/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

  • Added config/config.go with a collectConfigFiles(searchPaths, suffix) helper that scans directories for files matching a suffix and returns a deduplicated name→path map
  • Replaced inline directory scanning in LoadFeatures (config/feature.go) with a call to collectConfigFiles
  • Replaced inline directory scanning in LoadTransfers (config/transfer.go) with a call to collectConfigFiles
  • Introduced featureSuffix and transferSuffix constants for the .feature and .transfer file extensions

…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>
Comment thread config/transfer.go Outdated
transferFiles[component] = filepath.Join(dir, entry.Name())
}
}
transferFiles, err := collectConfigFiles(searchPaths, ".transfer")
Copy link
Copy Markdown
Contributor

@bsherman bsherman Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@frostyardyeti
Copy link
Copy Markdown
Contributor Author

frostyardyeti Bot commented Mar 30, 2026

— Automated by Yeti —

Addressed the review comment: added const transferSuffix = ".transfer" in config/transfer.go and used it in the collectConfigFiles call, matching the featureSuffix pattern already established in config/feature.go. All tests pass.

@frostyardyeti frostyardyeti Bot added the Ready Yeti has finished — needs human attention label Mar 30, 2026
@bketelsen bketelsen merged commit c408dd6 into main Mar 30, 2026
7 checks passed
@bketelsen bketelsen deleted the yeti/improve-ef00 branch March 30, 2026 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready Yeti has finished — needs human attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants