[repository-quality] 🎯 Repository Quality Improvement Report - Code Organization (2026-08-04) #50271
Closed
Replies: 1 comment
|
This discussion has been marked as outdated by Repository Quality Improvement Agent. A newer discussion is available at Discussion #50563. |
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 - Code Organization
Analysis Date: 2026-08-04
Focus Area: Code Organization
Strategy Type: Standard
Custom Area: No
Executive Summary
The gh-aw codebase (267K source LOC / 517K test LOC across 3,119 files under
pkg/) has a documented file-size guideline in.github/skills/developer-code-organization/SKILL.mdrecommending 100–500 line files, yet 15 non-test Go files currently exceed 1,000 lines and 83 exceed 600 lines. The largest offenders —pkg/workflow/awf_helpers.go(1,148 lines, 29 functions),pkg/cli/update_actions.go(1,144 lines, 18 functions), andpkg/workflow/compiler_custom_jobs.go(1,106 lines, 36 functions) — mix multiple unrelated concerns (feature-flag capability checks, command/arg building, job-property extraction) in single files, making them harder to navigate and review.These files are strong refactor candidates because their functions already cluster into clear, independently testable groups (e.g.,
awfSupports*capability-check functions form a naturalawf_capabilities.gofile;extractCustomJob*functions form a naturalcompiler_custom_jobs_extract.gofile). Splitting by functionality — consistent with the "Group by Functionality, Not by Type" pattern already documented — would reduce single-file cognitive load without changing behavior, and is low-risk since it is a pure code-move refactor covered by existing unit tests.We recommend tackling the three largest files first as independent, reviewable PRs, followed by tracking future large files with a lightweight lint/CI check.
Full Analysis Report
Focus Area: Code Organization
Current State Assessment
Metrics Collected:
pkg/pkg/workflow/awf_helpers.go(1,148 lines, 29 funcs)Findings
Strengths
developer-code-organizationskill) with good examples (create_issue.go,add_comment.go).Areas for Improvement
awf_helpers.gomixes AWF command building (BuildAWFCommand,BuildAWFArgs, ~600 lines) with unrelated capability-check predicates (awfSupports*, 10 small functions) and chroot config JSON builders.update_actions.gocombines action-version resolution (getLatestActionRelease*), git-based tag lookup, skill-ref updating, and workflow-file rewriting — four distinct responsibilities in one file.Detailed Analysis
pkg/workflow/awf_helpers.go(1,148 lines):BuildAWFCommand/BuildAWFArgs/GetAWFCommandPrefix— core AWF invocation building (~580 lines, cohesive, could stay or move toawf_command_builder.go).awfSupports*(firewallConfig *FirewallConfig) boolpredicates plusawfVersionAtLeast— a clean, extractable "capability matrix" module (~100 lines) → candidate for new filepkg/workflow/awf_capabilities.go.awf_chroot_config.go.pkg/cli/update_actions.go(1,144 lines):getLatestActionRelease*,getLatestActionReleaseViaGit,parseActionTagRefs,findCooledDownActionVersion,getActionSHAForTag) — candidate forupdate_actions_release_resolver.go.updateActionsInWorkflowFiles,updateSkillRefsInContent*,updateActionRefsInContentWithDeps) — candidate forupdate_actions_file_rewriter.go.pkg/workflow/compiler_custom_jobs.go(1,106 lines):extractCustomJob*property extractors (env, container, services, timeout, concurrency, outputs, etc.) — candidate forcompiler_custom_jobs_extract.go, leaving job-building orchestration (buildCustomJob*) in the main file.🤖 Tasks for Copilot Agent
NOTE TO PLANNER AGENT: Split the following tasks into individual work items.
Improvement Tasks
Task 1: Split AWF capability-check predicates out of awf_helpers.go
Priority: Medium
Estimated Effort: Small
Focus Area: Code Organization
Description: Extract the ten
awfSupports*boolean predicate functions plusawfVersionAtLeast(lines ~1041–1125 ofpkg/workflow/awf_helpers.go) into a new filepkg/workflow/awf_capabilities.go. This is a pure code move — no logic changes.Acceptance Criteria:
pkg/workflow/awf_capabilities.gocontains the moved functions with matching package/importspkg/workflow/awf_helpers.gono longer contains these functionsmake fmtandmake test-unit(or targetedgo test ./pkg/workflow/...) pass unchangedCode Region:
pkg/workflow/awf_helpers.golines 1041-1125 (awfSupports*,awfVersionAtLeastfunctions)Task 2: Split action-release resolution logic out of update_actions.go
Priority: Medium
Estimated Effort: Medium
Focus Area: Code Organization
Description: Extract the GitHub API/git-based action-version resolution functions (lines ~403–804 of
pkg/cli/update_actions.go) into a new filepkg/cli/update_actions_release_resolver.go, separating "how do we find the latest version" from "how do we rewrite files" concerns.Acceptance Criteria:
pkg/cli/update_actions_release_resolver.gocontainsgetLatestActionRelease,getLatestActionReleaseWithDeps,getLatestActionReleaseViaGit,parseActionTagRefs,findCooledDownActionVersion,getActionSHAForTagpkg/cli/update_actions.goreduced by ~400 lines with no behavior changemake fmtandgo test ./pkg/cli/...(or targeted subset) passCode Region:
pkg/cli/update_actions.golines 403-804Task 3: Extract custom job property extractors into a dedicated file
Priority: Low
Estimated Effort: Medium
Focus Area: Code Organization
Description: Move the 15
extractCustomJob*functions frompkg/workflow/compiler_custom_jobs.go(env, container, services, timeout, concurrency, outputs, continue-on-error, environment, runs-on extraction) into a new filepkg/workflow/compiler_custom_jobs_extract.go, leaving job orchestration (buildCustomJob,buildCustomJobs) in the original file.Acceptance Criteria:
pkg/workflow/compiler_custom_jobs_extract.gocontains allextractCustomJob*functionscompiler_custom_jobs.goreduced to job-building/orchestration logic (~500 lines)go test ./pkg/workflow/... -run TestCustomJob(or closest matching) passes unchangedCode Region:
pkg/workflow/compiler_custom_jobs.go(functions matchingextractCustomJob*)Task 4: Add a CI check to flag new Go files exceeding 800 lines
Priority: Low
Estimated Effort: Small
Focus Area: Code Organization
Description: The repository documents a 100–500 line file-size guideline but has no automated enforcement. Add a lightweight script (e.g.,
scripts/check-file-size.shor a Makefile target) that warns (non-blocking, informational) when non-test.gofiles underpkg/exceed 800 lines, to prevent further growth of already-large files while not blocking existing ones.Acceptance Criteria:
pkg/) and prints them as a warning, without failing the buildmake lintormake checktarget as advisory output only (non-blocking)Code Region: New file, e.g.
scripts/check-file-size.sh📊 Historical Context
Previous Focus Areas
🎯 Recommendations
Immediate Actions (This Week)
awf_helpers.gocapability predicates intoawf_capabilities.go— Priority: MediumShort-term Actions (This Month)
update_actions.gorelease-resolution logic — Priority: Mediumcompiler_custom_jobs.goproperty extractors — Priority: LowLong-term Actions (This Quarter)
📈 Success Metrics
Next Steps
Generated by Repository Quality Improvement Agent
Next analysis: 2026-08-05 — Focus area selected by diversity algorithm
All reactions