-
Notifications
You must be signed in to change notification settings - Fork 28
Closed
Description
Objective
Create a generic helper function to eliminate near-duplicate config parsing functions in pkg/workflow/config.go.
Context
The analysis identified that parseTitlePrefixFromConfig and parseTargetRepoFromConfig have ~90% code similarity, differing only in the key name, variable names, and log message text. This is Issue #1 from the semantic function clustering analysis (Priority 1: High Impact, Low Effort).
Related to #3478
Approach
- Create a new generic helper function
parseStringFromConfig(configMap map[string]any, key string) string - Implement the common pattern: check existence, type assertion, logging
- Refactor
parseTitlePrefixFromConfigto use the helper - Refactor
parseTargetRepoFromConfigto use the helper - Ensure all existing tests continue to pass
Files to Modify
pkg/workflow/config.go- Add generic helper and refactor existing functionspkg/workflow/config_test.go- Add tests for the new helper function (if file exists, or create it)
Acceptance Criteria
- Generic
parseStringFromConfighelper function created -
parseTitlePrefixFromConfigrefactored to use the helper -
parseTargetRepoFromConfigrefactored to use the helper - All existing tests pass
- New tests cover the generic helper function
- Code duplication reduced from ~90% to minimal
- Logging behavior preserved
Estimated Effort
30 minutes
Benefits
- Reduces code duplication
- Single source of truth for string config parsing
- Easier to add new config fields in the future
- Improved maintainability
Related to [refactor] 🔧 Semantic Function Clustering Analysis - Refactoring Opportunities #3478
AI generated by Plan Command for #3478
Copilot