Skip to content

[Code Quality] Refactor large workflow files exceeding 500 LOC #13411

@github-actions

Description

@github-actions

Description

The codebase has 189 large files exceeding 500 lines (10.7% of total files), contributing to a moderate code organization score of 14.3/25. Breaking down the largest files would improve maintainability and the overall quality score.

Current State

From Daily Code Metrics (2026-02-02):

  • Code Organization Score: 14.3/25 (57%) - Moderate
  • Large Files (>500 LOC): 189 files
  • Target Score: 20+ (80%) for "Good" rating

Focus areas with the most large files:

  • .github/workflows/ - workflow lock files (large by nature)
  • pkg/workflow/ - workflow processing logic
  • pkg/cli/ - command implementations

Suggested Changes

Phase 1: Identify Top Candidates (1 day)

Find the top 10-20 largest non-workflow files for refactoring:

# Find largest files (excluding generated lock files)
find pkg/ -name "*.go" -type f -exec wc -l {} + | sort -rn | head -20

Phase 2: Refactor Strategy (2-3 days)

For each large file (e.g., >800 LOC):

  1. Split by functionality: Extract distinct responsibilities into separate files
  2. Follow existing patterns: Use *_command.go, *_validation.go, *_test.go naming
  3. Preserve tests: Ensure all test coverage is maintained
  4. Update imports: Ensure all references are updated

Example - Large validator file:

  • validation_tools.go (1200 LOC) →
    • validation_tools_mcp.go (MCP server validation)
    • validation_tools_github.go (GitHub tools validation)
    • validation_tools_permissions.go (Permission checks)

Phase 3: Validation

  • MUST run make agent-finish after refactoring
  • All existing tests must pass
  • No regression in code quality metrics
  • Improved code organization score (target: 20+/25)

Files Affected

Prioritize refactoring in these directories:

  • pkg/workflow/ - core workflow logic (likely candidates)
  • pkg/cli/ - command implementations
  • pkg/parser/ - parsing logic

Exclude from refactoring:

  • .github/workflows/*.lock.yml - generated files, large by design
  • Test files - keep co-located with source code

Success Criteria

  • At least 10-15 large files refactored (reducing count from 189)
  • Code organization score improves to 20+/25 (80%+)
  • All tests pass (make test-unit)
  • No functionality changes or regressions
  • Follow repository patterns and conventions

Impact

  • Improves code organization score from 57% to 80%+
  • Enhances maintainability and readability
  • Makes codebase easier to navigate
  • Supports overall quality score improvement (current: 74.7/100)

Source

Extracted from Daily Code Metrics Report discussion #13328 (2026-02-02).

Issue identified in "Insights & Recommendations" section: "Refactor Large Files".

Priority

Medium - Quality improvement with measurable impact on code organization metrics

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 17, 2026, 5:23 AM UTC

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions