-
Notifications
You must be signed in to change notification settings - Fork 292
Open
Labels
Description
Overview
Semantic analysis found a large duplicated parsing block between project-related safe-output config parsers. The duplication covers view parsing and field-definition parsing logic and is significant enough to warrant extraction into shared helpers.
Critical Information
- Severity: High
- Pattern type: Structural duplication
- Occurrences: 2 major occurrences
- Estimated duplicated size: ~100+ lines
- Commit analyzed:
b00338445c8308b1244fee1a182248509d0ccb40
Duplication Details
-
Primary locations:
pkg/workflow/create_project.go((*Compiler).parseCreateProjectsConfig, lines 17-164)pkg/workflow/update_project.go((*Compiler).parseUpdateProjectConfig, lines 33-172)
-
Repeated sub-block examples:
visible-fieldsparsing appears in both methods:pkg/workflow/create_project.golines 80-85pkg/workflow/update_project.golines 88-93
field-definitionsparsing appears in both methods:pkg/workflow/create_project.golines 110-144pkg/workflow/update_project.golines 118-152
Code Sample (Representative Duplicate Block)
// Parse field-definitions if specified
fieldsData, hasFields := configMap["field-definitions"]
if !hasFields {
fieldsData, hasFields = configMap["field_definitions"]
}
if hasFields {
if fieldsList, ok := fieldsData.([]any); ok {
for i, fieldItem := range fieldsList {
fieldMap, ok := fieldItem.(map[string]any)
if !ok {
continue
}
field := ProjectFieldDefinition{}
// ... parse name, data-type/data_type, options ...
if field.Name != "" && field.DataType != "" {
cfg.FieldDefinitions = append(cfg.FieldDefinitions, field)
}
}
}
}Impact Analysis
- Maintainability: Fixes to parsing rules must be repeated in both code paths.
- Bug risk: Divergence risk is high (e.g., one path accepts new schema aliases while the other does not).
- Code bloat: Large duplicated loops and field-mapping logic increase review and test burden.
Refactoring Recommendations
- Extract shared project parser helpers
- Add helper(s) for parsing
viewsandfield-definitions, reused by both create/update paths. - Suggested location:
pkg/workflow/project_config_parsing.go. - Estimated effort: Medium (2-4 hours including tests).
- Unify project-specific envelope parsing
- Keep command-specific fields (
title-prefixvsproject) in thin wrappers, but delegate common body parsing. - Benefit: single source of truth for schema alias handling and validation.
- Add regression tests for shared helpers
- Ensure identical behavior for both create/update entry points using table-driven fixtures.
Implementation Checklist
- Extract shared parser for
views - Extract shared parser for
field-definitions - Wire both
parseCreateProjectsConfigandparseUpdateProjectConfigto shared helpers - Add parity tests covering both command paths
- Verify no behavior regressions in existing workflow compilation tests
Analysis Metadata
- Detection method: Serena semantic analysis (
get_symbols_overview,find_symbol,search_for_pattern) - Scope analyzed: non-test Go code in
pkg/workflowfrom current commit snapshot - Workflow run: §23079853425
References:
Generated by Duplicate Code Detector · ◷
Warning
⚠️ Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
ab.chatgpt.com
To allow these domains, add them to the network.allowed list in your workflow frontmatter:
network:
allowed:
- defaults
- "ab.chatgpt.com"See Network Configuration for more information.
Reactions are currently unavailable