Skip to content

[task] Consolidate duplicate config parsing functions in config.go #3485

@github-actions

Description

@github-actions

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

  1. Create a new generic helper function parseStringFromConfig(configMap map[string]any, key string) string
  2. Implement the common pattern: check existence, type assertion, logging
  3. Refactor parseTitlePrefixFromConfig to use the helper
  4. Refactor parseTargetRepoFromConfig to use the helper
  5. Ensure all existing tests continue to pass

Files to Modify

  • pkg/workflow/config.go - Add generic helper and refactor existing functions
  • pkg/workflow/config_test.go - Add tests for the new helper function (if file exists, or create it)

Acceptance Criteria

  • Generic parseStringFromConfig helper function created
  • parseTitlePrefixFromConfig refactored to use the helper
  • parseTargetRepoFromConfig refactored 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

AI generated by Plan Command for #3478

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions