Summary
Several helpers in frontmatter_extraction_yaml.go repeat the same nested frontmatter["on"] traversal and value-normalization pattern for different triggers. The shape is duplicated across deployment status, workflow-run conclusion, slash-command, and label-command parsing.
Duplication Details
pkg/workflow/frontmatter_extraction_yaml.go:869-915
pkg/workflow/frontmatter_extraction_yaml.go:938-995
pkg/workflow/frontmatter_extraction_yaml.go:1016-1099
pkg/workflow/frontmatter_extraction_yaml.go:1102-1165
Impact
- Each new
on.* trigger variant risks adding another copy of the same map-walking and normalization logic.
- Bug fixes to one parser path can be missed in the others, especially around validation and empty-value handling.
Refactoring Recommendation
Extract a small helper for nested on-section lookup and another for normalizing scalar-or-array values into a string slice. The trigger-specific helpers can then focus on validation and expression rendering instead of repeating frontmatter plumbing.
Code Sample
onValue, ok := frontmatter["on"]
onMap, ok := onValue.(map[string]any)
childValue, ok := onMap["workflow_run"]
...
if s, ok := value.(string); ok {
conclusions = []string{s}
} else {
conclusions = parseStringSliceAny(value, nil)
}
Analysis Metadata
- Commit: 27e0d8d
- Detection Method: Serena semantic code analysis + local source inspection
Generated by 🔍 Duplicate Code Detector · 78.6 AIC · ⌖ 12.1 AIC · ⊞ 14.8K · ◷
Summary
Several helpers in
frontmatter_extraction_yaml.gorepeat the same nestedfrontmatter["on"]traversal and value-normalization pattern for different triggers. The shape is duplicated across deployment status, workflow-run conclusion, slash-command, and label-command parsing.Duplication Details
pkg/workflow/frontmatter_extraction_yaml.go:869-915pkg/workflow/frontmatter_extraction_yaml.go:938-995pkg/workflow/frontmatter_extraction_yaml.go:1016-1099pkg/workflow/frontmatter_extraction_yaml.go:1102-1165Impact
on.*trigger variant risks adding another copy of the same map-walking and normalization logic.Refactoring Recommendation
Extract a small helper for nested
on-section lookup and another for normalizing scalar-or-array values into a string slice. The trigger-specific helpers can then focus on validation and expression rendering instead of repeating frontmatter plumbing.Code Sample
Analysis Metadata