Skip to content

[duplicate-code] Duplicate Code: Glob List Validation Across Workflow Validators #42429

Description

@github-actions

🔍 Duplicate Code Detected: Glob List Validation Across Workflow Validators

Analysis of commit 1ffa6eb

Summary

validateGlobList and validateRefGlobList both implement the same list-walk + pattern-check + aggregated error formatting flow. The shared shape is: read a list, iterate entries, validate each pattern, collect messages, and return a field-specific error.

Duplication Details

Pattern: Shared glob-list validation flow

  • Severity: Medium
  • Occurrences: 2
  • Locations:
    • pkg/workflow/compiler_filters_validation.go (lines 186-221)
    • pkg/workflow/safe_outputs_validation.go (lines 234-244)
  • Code Sample:
    for _, pat := range patterns {
        if errs := validateRefGlob(pat); len(errs) > 0 {
            msgs := make([]string, 0, len(errs))
            for _, e := range errs {
                msgs = append(msgs, e.Message)
            }
            return fmt.Errorf(...)
        }
    }

Impact Analysis

  • Maintainability: Pattern validation and error shaping drift apart easily across validators.
  • Bug Risk: Fixes to glob handling or message wording can land in one path and not the other.
  • Code Bloat: Each module reimplements the same iteration and message aggregation logic.

Refactoring Recommendations

  1. Extract a shared helper for list-based glob validation.
    • Parameterize the element validator, field path, and error constructor.
    • Estimated effort: small.
  2. Reuse the helper for both ref and path lists.
    • Keeps the compiler filter and safe-outputs validators aligned.

Implementation Checklist

  • Review duplication findings
  • Prioritize refactoring tasks
  • Create refactoring plan
  • Implement changes
  • Update tests
  • Verify no functionality broken

Analysis Metadata

  • Analyzed Files: 2
  • Detection Method: Serena semantic code analysis
  • Commit: 1ffa6eb
  • Analysis Date: 2026-06-30

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • awmgmcpg
  • proxy.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"
    - "proxy.golang.org"

See Network Configuration for more information.

Generated by 🔍 Duplicate Code Detector · 7.02 AIC · ⊞ 13.7K ·

  • expires on Jul 1, 2026, 10:44 PM UTC-08:00

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions