Skip to content

[lint-monster] Function-length refactoring: 635 functions exceed 60-line limit #36564

@github-actions

Description

@github-actions

Summary

Daily custom lint scan identified 635 functions exceeding the 60-line length limit across pkg/workflow, pkg/cli, and pkg/parser.

Root Cause

Functions with complex logic or many sequential operations have accumulated beyond the target limit of 60 lines. This affects code readability, testability, and maintenance.

Affected Subsystems

  • pkg/workflow/ - largest concentration (majority of 635 findings)
  • pkg/cli/ - several functions in various commands
  • pkg/parser/ - a few parser and validation functions

Example Functions (representative sample)

  • buildMaintenanceWorkflowYAML (936 lines) in maintenance_workflow_yaml.go
  • buildPreActivationJob (489 lines) in compiler_pre_activation_job.go
  • commentOutProcessedFieldsInOnSection (625 lines) in frontmatter_extraction_yaml.go
  • GetExecutionSteps (565 lines) in copilot_engine_execution.go
  • GetExecutionSteps (382 lines) in claude_engine.go
  • Many functions in range 100-300 lines

Remediation Strategy

Refactor functions into smaller, focused helpers. See validation-refactoring.md for guidelines:

Approach

  1. Extract helper functions for distinct logical sections
  2. Use option structs to pass complex parameters
  3. Create intermediate builders for multi-step operations
  4. Maintain existing public APIs; internal helpers can be private
  5. Add comprehensive unit tests for extracted functions
  6. Run make golint-custom after refactoring to validate

Validation Checklist

  • All extracted functions <= 60 lines
  • No new linter errors introduced
  • Public API unchanged (backward compatible)
  • Unit tests pass: go test -v ./...
  • Full lint passes: make golint-custom

Next Steps (Prioritized)

  1. Ultra-long functions (>300 lines): buildMaintenanceWorkflowYAML (936), commentOutProcessedFieldsInOnSection (625), buildPreActivationJob (489), GetExecutionSteps copilot (565)
  2. Long engine functions (200-300 lines): Various GetExecutionSteps, log parsing functions
  3. Medium functions (100-200 lines): Builder functions, configuration parsers
  4. Remaining functions (60-100 lines): Final pass

Estimated Effort

This is a large, multi-session refactoring task. Recommend slicing by subsystem or function-size tier.

Labels

lint-monster, refactoring, code-quality

Generated by 🧌 LintMonster · haiku45 75K ·

  • expires on Jun 10, 2026, 3:51 AM UTC

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions