🔍 Duplicate Code Detected: Safe-Output Parser Wrappers
Analysis of commit c993af6
Assignee : @copilot
Summary
Many safe-output handlers already rely on the shared parseConfigScaffold helper, but each caller still repeats the same outer wrapper structure: optional preprocessing, the parseConfigScaffold(...) call, nil/default handling, and a small amount of post-parse logging or policy wiring. This pattern appears in at least 16 non-test Go files under pkg/workflow.
📊 Duplication Details - 2026-08-11
Duplication Details
Pattern: parseConfigScaffold wrapper functions
Severity : Medium
Occurrences : 16 wrappers
Locations :
pkg/workflow/add_labels.go:23 (parseAddLabelsConfig)
pkg/workflow/assign_to_user.go:40 (parseAssignToUserConfig)
pkg/workflow/unassign_from_user.go:19 (parseUnassignFromUserConfig)
pkg/workflow/set_issue_field.go:17 (parseSetIssueFieldConfig)
pkg/workflow/set_issue_type.go:19 (parseSetIssueTypeConfig)
pkg/workflow/mark_pull_request_as_ready_for_review.go:19 (parseMarkPullRequestAsReadyForReviewConfig)
Code Sample :
config := parseConfigScaffold (outputMap , "set-issue-type" , setIssueTypeLog , func (err error ) * SetIssueTypeConfig {
setIssueTypeLog .Printf ("Failed to unmarshal set-issue-type config, disabling handler: %v" , err )
return nil
})
if config != nil {
setIssueTypeLog .Printf ("Parsed configuration: allowed_count=%d, target=%s" , len (config .Allowed ), config .Target )
}
return config
Impact Analysis
Maintainability : Error-policy changes and defaulting rules have to be copied into many wrappers instead of changed once.
Bug Risk : Handler behavior can drift when one wrapper gets a default-max or postprocessing fix that peers miss.
Code Bloat : The shared parsing intent is hidden behind many nearly identical file-level wrappers.
Refactoring Recommendations
Add a higher-level scaffold for common parser policies
Extend pkg/workflow/config_helpers.go with a descriptor-based helper for fallback policy, default max handling, and post-parse hooks.
Estimated effort: medium.
Benefits: one place for parse failure behavior and common postprocessing.
Group simple handlers behind declarative parser descriptors
Convert the most repetitive wrappers first (add-labels, remove-labels, set-issue-*, assign/unassign).
Estimated effort: medium.
Benefits: smaller handler files and lower drift risk.
Implementation Checklist
Analysis Metadata
Analyzed Files : 1220 changed non-test Go files, with semantic focus on pkg/workflow
Detection Method : Serena semantic code analysis plus targeted pattern search
Commit : c993af6e74f88f7b414d54580b94f3f545b32864
Analysis Date : 2026-08-11T22:09:51Z
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
To allow these domains, add them to the network.allowed list in your workflow frontmatter:
network :
allowed :
- defaults
- " proxy.golang.org"
See Network Configuration for more information.
Generated by 🔍 Duplicate Code Detector · gpt54 · 118.3 AIC · ⊞ 12.8K · ◷
🔍 Duplicate Code Detected: Safe-Output Parser Wrappers
Analysis of commit c993af6
Assignee:
@copilotSummary
Many safe-output handlers already rely on the shared
parseConfigScaffoldhelper, but each caller still repeats the same outer wrapper structure: optional preprocessing, theparseConfigScaffold(...)call, nil/default handling, and a small amount of post-parse logging or policy wiring. This pattern appears in at least 16 non-test Go files underpkg/workflow.📊 Duplication Details - 2026-08-11
Duplication Details
Pattern:
parseConfigScaffoldwrapper functionspkg/workflow/add_labels.go:23(parseAddLabelsConfig)pkg/workflow/assign_to_user.go:40(parseAssignToUserConfig)pkg/workflow/unassign_from_user.go:19(parseUnassignFromUserConfig)pkg/workflow/set_issue_field.go:17(parseSetIssueFieldConfig)pkg/workflow/set_issue_type.go:19(parseSetIssueTypeConfig)pkg/workflow/mark_pull_request_as_ready_for_review.go:19(parseMarkPullRequestAsReadyForReviewConfig)Impact Analysis
Refactoring Recommendations
Add a higher-level scaffold for common parser policies
pkg/workflow/config_helpers.gowith a descriptor-based helper for fallback policy, default max handling, and post-parse hooks.Group simple handlers behind declarative parser descriptors
add-labels,remove-labels,set-issue-*, assign/unassign).Implementation Checklist
parseConfigScaffoldcallers by fallback policyAnalysis Metadata
pkg/workflowc993af6e74f88f7b414d54580b94f3f545b32864Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
proxy.golang.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.