Repository Quality Report: Large File Complexity & Code Size Management (2026-03-24) #22700
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Repository Quality Improvement Agent. A newer discussion is available at Discussion #22907. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
🎯 Repository Quality Improvement Report — Large File Complexity
Analysis Date: 2026-03-24
Focus Area: Large File Complexity & Code Size Management
Strategy Type: Custom (repository-specific)
Custom Area: Yes — gh-aw's
AGENTS.mdexplicitly documents a 300-line hard limit for validators and 100–200 line target, yet 163 source files exceed this threshold. This analysis identifies the highest-priority refactoring opportunities.Executive Summary
The
gh-awcodebase documents clear size guidelines: validators should target 100–200 lines with a hard limit of 300 lines. However, a sweep across all non-test Go files reveals 163 files exceeding 300 lines and 72 files exceeding 500 lines — indicating the size discipline applied to validators has not been consistently applied to the broader codebase.The most impactful offenders are non-validator files that have grown into multi-concern monoliths:
gateway_logs.go(1,127 lines combining types, parsing, rendering, and analytics),constants.go(1,093 lines of mixed-domain constants),trial_command.go(1,007 lines mixing CLI wiring with business logic), andcompiler_safe_outputs_config.go(976 lines). Additionally, several validator files themselves now exceed the 300-line hard limit.Splitting these files improves discoverability, testability, and maintainability — and aligns the non-validator codebase with the same quality bar already documented for validators.
Full Analysis Report
Focus Area: Large File Complexity
Current State Assessment
Metrics Collected:
Top 10 Largest Non-Validator Files:
pkg/cli/gateway_logs.gopkg/constants/constants.gopkg/workflow/safe_outputs_tools_filtering.gopkg/cli/trial_command.gopkg/workflow/checkout_manager.gopkg/workflow/compiler_safe_outputs_config.gopkg/cli/logs_report.gopkg/workflow/frontmatter_types.gopkg/cli/logs_orchestrator.gopkg/workflow/compiler_orchestrator_workflow.goValidator Files Exceeding Hard Limit (300 lines):
pkg/workflow/safe_outputs_validation_config.gopkg/workflow/safe_outputs_validation.gopkg/workflow/dispatch_workflow_validation.gopkg/workflow/tools_validation.gopkg/workflow/permissions_validation.gopkg/cli/run_workflow_validation.gopkg/workflow/repository_features_validation.gopkg/workflow/template_injection_validation.gopkg/workflow/mcp_config_validation.goFindings
Strengths
fmt.Printlnis appropriately used only for structured stdout output (18 occurrences, all justified)console.FormatErrorMessage, etc.) is consistently appliedAreas for Improvement
pkg/constants/constants.go(1,093 lines) — one file for all constants across all domains violates cohesionpkg/cli/gateway_logs.go(1,127 lines) — contains 13+ functions spanning type definitions, JSON parsing, RPC analysis, and table renderingcmd/gh-aw/main.go(862 lines) — command registration and CLI wiring in a single filepkg/workflow/frontmatter_types.go(917 lines) — all frontmatter types in one fileDetailed Analysis
Why
constants.goshould be split:The file contains 141 type definitions and constants spanning engine versions, MCP URLs, runtime defaults, job names, step IDs, firewall configuration, playground settings, and language support maps. A grep of section boundaries shows clear domain groupings that map cleanly to separate files.
Why
gateway_logs.goshould be split:Functions include
parseRPCMessages(170–341),parseGatewayLogs(357–433),processGatewayLogEntry(434–541),renderGatewayMetricsTable(580–707), andbuildToolCallsFromRPCMessages(719–860). These span distinct concerns: type definitions, I/O parsing, metric computation, and rendering.Why validator overruns matter:
AGENTS.md documents these limits as guardrails against complexity. When validators silently exceed their limits, it signals that the review checklist is not enforcing the constraint. Fixing the validators restores the documented quality bar.
🤖 Tasks for Copilot Agent
NOTE TO PLANNER AGENT: The following 5 tasks are designed for GitHub Copilot coding agent execution. Please split these into individual work items for the agent to process one at a time.
Improvement Tasks
Task 1: Split
pkg/constants/constants.gointo Domain-Specific FilesPriority: High
Estimated Effort: Medium
Focus Area: Code Organization
Description:
pkg/constants/constants.gois 1,093 lines and contains constants spanning multiple unrelated domains: semantic type definitions, engine versions, MCP configuration, runtime defaults, job/step names, firewall settings, and playground parameters. Split it into cohesive domain files inpkg/constants/.Acceptance Criteria:
constants.goreduced to ≤ 300 lines (or ideally ≤ 200)constants_engines.go,constants_mcp.go,constants_runtimes.go,constants_types.go,constants_jobs.goconstantspackage — no import path changesmake build && make test-unitpassesCode Region:
pkg/constants/constants.goTask 2: Split
pkg/cli/gateway_logs.gointo Focused Sub-FilesPriority: High
Estimated Effort: Medium
Focus Area: Code Organization
Description:
pkg/cli/gateway_logs.gois 1,127 lines and contains at least 4 distinct concerns: type definitions, file I/O parsing, metric aggregation, and table rendering. Split into cohesive files inpkg/cli/.Acceptance Criteria:
gateway_logs.gois either removed or reduced to ≤ 300 linesgateway_logs_types.go,gateway_logs_parsing.go,gateway_logs_metrics.go,gateway_logs_rendering.gopackage climake build && make test-unitpassesCode Region:
pkg/cli/gateway_logs.goTask 3: Split Oversized Validator Files Back Below 300-Line Hard Limit
Priority: Medium
Estimated Effort: Medium
Focus Area: Validation Complexity
Description:
The following validator files exceed the documented 300-line hard limit in
AGENTS.md:safe_outputs_validation.go(407),safe_outputs_validation_config.go(407),dispatch_workflow_validation.go(363),tools_validation.go(359), andpermissions_validation.go(351). Apply the same split strategy documented inscratchpad/validation-refactoring.md.Acceptance Criteria:
{domain}_{subdomain}_validation.goconventionmake build && make test-unit && make lintpassesCode Region:
pkg/workflow/safe_outputs_validation.go,pkg/workflow/safe_outputs_validation_config.go,pkg/workflow/dispatch_workflow_validation.go,pkg/workflow/tools_validation.go,pkg/workflow/permissions_validation.goTask 4: Slim Down
cmd/gh-aw/main.goby Extracting Command RegistrationPriority: Medium
Estimated Effort: Small
Focus Area: Code Organization
Description:
cmd/gh-aw/main.gois 862 lines and contains all command registrations, flag definitions, and CLI wiring inline. The file should focus on bootstrapping and delegate command registration to helper functions or sub-files. Target: ≤ 400 lines for main.go.Acceptance Criteria:
cmd/gh-aw/main.goreduced to ≤ 400 linespackage maincmd/gh-aw/commands_workflow.go,cmd/gh-aw/commands_mcp.go)./gh-aw --helpand all subcommands still function correctlymake build && make test-unitpassesCode Region:
cmd/gh-aw/main.goTask 5: Add File-Size Enforcement to CI
Priority: Low
Estimated Effort: Small
Focus Area: CI/CD Quality Gates
Description:
The 300-line hard limit for validators is documented but not enforced automatically. Add a lightweight CI check (bash script or Makefile target) that fails if any file in
pkg/workflow/*validation*.goorpkg/cli/*validation*.goexceeds 300 lines. This prevents future regressions.Acceptance Criteria:
make check-file-sizestarget in Makefile*validation*.gofiles.github/workflows/ci.yml) runs this checkmake check-file-sizescurrently fails (existing violations) — document in PR that existing violations are tracked issuesCode Region:
Makefile,.github/workflows/ci.yml📊 Historical Context
Previous Focus Areas
🎯 Recommendations
Immediate Actions (This Week)
constants.go(Task 1) — pure mechanical refactor, zero behavior change, high discoverability gain — Priority: Highgateway_logs.go(Task 2) — 1,127 lines is untenable; clear domain separation already exists in the functions — Priority: HighShort-term Actions (This Month)
cmd/gh-aw/main.go(Task 4) — improves first-impressions for new contributors — Priority: MediumLong-term Actions (This Quarter)
📈 Success Metrics
Track these metrics to measure improvement in Large File Complexity:
constants.gosize: 1,093 lines → target ≤ 200 linesgateway_logs.gosize: 1,127 lines → target 0 (fully split)main.gosize: 862 lines → target ≤ 400 linesNext Steps
make check-file-sizesonce Task 5 landsGenerated by Repository Quality Improvement Agent
Next analysis: 2026-03-25 — Focus area will be selected based on diversity algorithm
References:
Beta Was this translation helpful? Give feedback.
All reactions