Skip to content

[Code Quality] Refactor oversized compiler_activation_jobs.go file #13657

@github-actions

Description

@github-actions

Description

The pkg/workflow/compiler_activation_jobs.go file has grown to 820 lines, significantly exceeding the ideal 300-600 line range for maintainability. The file contains 4 large functions averaging 205 lines each, making it difficult to navigate, understand, and maintain.

Problem

  • File size: 820 lines (exceeds 600-line ideal by 37%)
  • Function length: Average 205 lines per function (ideal: 10-30 lines, max 50)
  • Maintainability: Difficult to navigate and understand the full scope
  • Testing: Large functions are harder to test in isolation

Suggested Changes

Split the file into 3 focused modules based on job type:

Proposed File Structure

  1. compiler_activation_jobs_pre.go (~250-300 lines)

    • Pre-activation job logic
    • Membership checks
    • Stop-time validation
    • buildPreActivationJob() function
    • extractPreActivationCustomFields() function
  2. compiler_activation_jobs_main.go (~250-300 lines)

    • Main activation job logic
    • Activation dependencies
    • buildActivationJob() function
  3. compiler_activation_jobs_agent.go (~250-300 lines)

    • Agent job orchestration
    • Main job building
    • buildMainJob() function

Additional Improvements

Extract helper functions from long functions:

// Extract permission setup logic
func (c *Compiler) generatePermissionsForActivation(data *WorkflowData) *Permissions

// Extract reaction step generation
func (c *Compiler) addReactionSteps(steps []string, reaction string) []string

// Extract membership check steps
func (c *Compiler) generateMembershipCheckSteps(data *WorkflowData) []string

Files Affected

  • pkg/workflow/compiler_activation_jobs.go (to be split)
  • pkg/workflow/compiler_activation_jobs_test.go (may need updates)

Success Criteria

  • Original file split into 3 focused files (~250-300 lines each)
  • All functionality preserved (no behavior changes)
  • All existing tests continue to pass
  • Test coverage maintained (current: 0.57 test-to-source ratio)
  • Average function length reduced to <100 lines
  • Imports updated across the codebase
  • Code review confirms improved readability

Impact

  • Maintainability: Significantly improves code navigation and understanding
  • Testability: Easier to test smaller, focused functions
  • Effort: 1-2 days estimated
  • Priority: High - Prevents technical debt accumulation

Source

Extracted from Daily Compiler Code Quality Report - 2026-02-03 discussion #13521

Quotes from source:

"File Size (High Priority): Current: 820 lines. Ideal: 300-600 lines. Impact: Difficult to navigate, understand, and maintain"

"Recommendation: Split into 2-3 focused files based on job type"

Priority

High - Prevents further technical debt accumulation in a core compiler file

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 18, 2026, 5:21 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