Skip to content

Refactor six non-workflow large functions via targeted helper extraction - #48535

Merged
pelikhan merged 3 commits into
mainfrom
copilot/lint-monster-function-length-cleanup
Jul 28, 2026
Merged

Refactor six non-workflow large functions via targeted helper extraction#48535
pelikhan merged 3 commits into
mainfrom
copilot/lint-monster-function-length-cleanup

Conversation

Copilot AI commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

This PR addresses the non-workflow largefunc findings identified by lint-monster by splitting the six flagged functions/literals into smaller, cohesive helpers without changing behavior. Scope is limited to the reported parser, CLI entrypoint, and linter-registry/analyzer paths.

  • CLI compile/run wiring cleanup (cmd/gh-aw/main.go)

    • Replaced oversized compile RunE literal with named orchestration helpers:
      • runCompileCommand
      • readCompileFlags / resolveCompileGhAwRef
      • buildCompileConfig
    • Split oversized init setup flow into focused setup units:
      • root command setup, usage rendering, custom help wiring
      • command creation/grouping/registration
      • flag and completion registration
    • Preserved existing flag surface and command behavior while reducing function size hotspots.
  • Git fallback clone flow split (pkg/parser/remote_download_file.go)

    • Broke downloadFileViaGitClone into phase-specific helpers:
      • input validation, temp dir creation, repo URL construction
      • SHA clone+checkout path vs branch/tag clone path
      • validated file read from clone root
    • Kept existing fallback semantics and error text shape.
  • Analyzer logic decomposition (pkg/linters/stringbytesroundtrip/stringbytesroundtrip.go)

    • Refactored analyzeRoundTrip into discrete helpers for:
      • call-shape extraction
      • skip filtering (generated / nolint)
      • type extraction
      • diagnostic emission per pattern (string([]byte(s)) vs []byte(string(b)))
    • Diagnostic messages and detection semantics remain unchanged.
  • Registry All simplification (pkg/linters/registry.go)

    • Moved analyzer list literal into package-level allAnalyzers.
    • All() now returns a defensive copy via append([]*analysis.Analyzer(nil), allAnalyzers...) to preserve caller isolation while eliminating oversized function body.
func All() []*analysis.Analyzer {
	return append([]*analysis.Analyzer(nil), allAnalyzers...)
}

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix function length issues in non-workflow subsystems Refactor six non-workflow large functions via targeted helper extraction Jul 28, 2026
Copilot AI requested a review from pelikhan July 28, 2026 06:28
@github-actions

Copy link
Copy Markdown
Contributor

PR Triage

  • Category: refactor | Risk: medium | Score: 45/100
  • Impact 25 · Urgency 10 · Quality 10
  • Recommended action: defer

Mechanical lint-monster function-splitting cleanup. Draft, no CI signal yet. Low urgency — safe to defer until undrafted and CI runs.

Generated by 🔧 PR Triage Agent · sonnet50 · 50.9 AIC · ⌖ 5.23 AIC · ⊞ 7.5K ·

@pelikhan
pelikhan marked this pull request as ready for review July 28, 2026 07:34
Copilot AI review requested due to automatic review settings July 28, 2026 07:34
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts on this branch.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors six largefunc findings into focused helpers while preserving existing behavior.

Changes:

  • Decomposes CLI compilation, initialization, usage, and command registration.
  • Splits Git clone fallback into phase-specific helpers.
  • Simplifies analyzer logic and linter registry construction.
Show a summary per file
File Description
cmd/gh-aw/main.go Extracts CLI orchestration and setup helpers.
pkg/parser/remote_download_file.go Decomposes Git clone fallback logic.
pkg/linters/stringbytesroundtrip/stringbytesroundtrip.go Splits round-trip analysis into focused helpers.
pkg/linters/registry.go Moves analyzers into a package-level registry with defensive copying.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment on lines +432 to 434
githubHost := GetGitHubHostForRepo(owner, repo)
if host != "" {
githubHost = "https://" + host
…ain.go

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts on this branch.

Resolved in commit 0d7b6bc. The only true conflict was in cmd/gh-aw/main.go where both branches modified the compileCmd.RunE — main had reverted to the inline approach (with supporting changes in pkg/cli/). I accepted main's version of that file. The refactoring of the other three files (pkg/parser/remote_download_file.go, pkg/linters/registry.go, pkg/linters/stringbytesroundtrip/stringbytesroundtrip.go) was preserved through the merge since main hadn't touched them. All unit tests pass.

@pelikhan
pelikhan merged commit 05db336 into main Jul 28, 2026
28 checks passed
@pelikhan
pelikhan deleted the copilot/lint-monster-function-length-cleanup branch July 28, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[lint-monster] Non-workflow function-length cleanup (2026-07-26)

3 participants