Skip to content

Address leftover golint findings in CLI init/compile flow, stringsconcatloop analyzer, and actionpins test set usage - #49752

Merged
pelikhan merged 3 commits into
mainfrom
copilot/fix-leftover-golint-findings
Aug 2, 2026
Merged

Address leftover golint findings in CLI init/compile flow, stringsconcatloop analyzer, and actionpins test set usage#49752
pelikhan merged 3 commits into
mainfrom
copilot/fix-leftover-golint-findings

Conversation

Copilot AI commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

This PR resolves the remaining non-shared golint findings called out in the daily scan: three largefunc findings in cmd/gh-aw/main.go, one largefunc in pkg/linters/stringsconcatloop/stringsconcatloop.go, and one map-as-set finding in pkg/actionpins/actionpins_internal_test.go.
The change is structural only: behavior and external interfaces are preserved.

  • cmd/gh-aw/main.go — split oversized command/setup logic

    • Extracted compile command execution into focused helpers (runCompileCmd, compile option parsing/normalization, config assembly).
    • Decomposed large init() responsibilities into smaller setup functions (root command config, command creation, flag wiring, grouping, registration, help usage wiring).
    • Replaced long inline usage/help function literals with named helpers to remove largefunc hits while keeping output semantics intact.
  • pkg/linters/stringsconcatloop/stringsconcatloop.go — decompose analyzer run path

    • Broke run into narrower helpers for:
      • assignment pattern extraction (+= and x = x + y),
      • loop/nolint/generated-file gating,
      • final report eligibility.
    • Preserved analyzer behavior and reporting message.
  • pkg/actionpins/actionpins_internal_test.go — remove map-as-set pattern

    • Reworked the warning-preservation assertion to avoid constructing a map[string]bool as an expected set.
    • Assertion now validates size and key presence directly.
assert.Len(t, ctx.Warnings, 1)
assert.True(t, ctx.Warnings["actions/checkout@v5"])

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix leftover golint findings in multiple locations Address leftover golint findings in CLI init/compile flow, stringsconcatloop analyzer, and actionpins test set usage Aug 2, 2026
Copilot AI requested a review from pelikhan August 2, 2026 10:56
@pelikhan
pelikhan marked this pull request as ready for review August 2, 2026 11:16
Copilot AI review requested due to automatic review settings August 2, 2026 11:16

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 CLI setup and analyzer logic to resolve lint findings without changing behavior.

Changes:

  • Extracts compile, initialization, and help logic into focused helpers.
  • Decomposes string-concatenation analyzer processing.
  • Simplifies action-pin warning assertions.
Show a summary per file
File Description
cmd/gh-aw/main.go Splits oversized CLI functions.
pkg/linters/stringsconcatloop/stringsconcatloop.go Extracts analyzer helpers.
pkg/actionpins/actionpins_internal_test.go Removes the expected map-as-set pattern.

Review details

Tip

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

  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

PR Triage

  • Category:
  • Risk:
  • Priority: (score: 40/100)
    • Impact: 14/50, Urgency: 10/30, Quality: 16/20
  • Recommended action:
  • Batch:

Automated triage — see full report issue for details.

Structured data:

{
  "action": "batch_review",
  "category": "chore",
  "pr_number": 49752,
  "risk": "medium"
}

Generated by 🔧 PR Triage Agent · auto · 73.4 AIC · ⌖ 3.47 AIC · ⊞ 8K ·

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR does not have the implementation label and has ≤100 new lines of code in business logic directories (77 additions across 3 files).

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

Test Quality Score: N/A — Infrastructure

Infrastructure-only change detected. Only 2 additions and 4 deletions to test infrastructure; no new test functions were added.

📊 Refactoring Summary
File Change Type Behavioral Tests Added Behavioral Tests Modified
pkg/actionpins/actionpins_internal_test.go Test refactoring 0 0 (internal refactor)

Analysis:

  • 1 test modified: TestInitWarnings/preserves_existing_warnings_map
  • Change: Refactored assertion from defensive equality check to two focused assertions (Len + True)
  • Impact: Improves test clarity without altering behavioral coverage
  • Violations: 0
  • Goroutine-leak guards: Not applicable

Verdict

passed. Test-only refactoring with improved assertion clarity. No behavioral tests were added or modified; existing coverage remains intact. No violations detected.

🧪 Test quality analysis by Test Quality Sentinel · haiku45 · 13 AIC · ⌖ 6.71 AIC · ⊞ 8.4K ·
Comment /review to run again

@github-actions github-actions Bot 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.

✅ Test Quality Sentinel: Infrastructure only. Test refactoring with improved assertion clarity. No behavioral tests were added or modified. No violations detected.

@github-actions github-actions Bot 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.

The refactoring is clean and correct — behavior is preserved across all three changed files.

  • cmd/gh-aw/main.go: compileCmdOptions struct + extracted helpers (runCompileCmd, getCompileCmdOptions, resolveGhAwRef, toCompileConfig) are semantically equivalent to the original inline code. fixPathForCommand extraction is safe. commandSet struct neatly groups commands without changing initialization logic.
  • pkg/linters/stringsconcatloop/stringsconcatloop.go: shouldReportLoopConcat, collectConcatLoopAssignment, concatAssignmentLHS, and selfReferentialConcatLHS correctly decompose the original run body. The combined nolint-check (||) and per-iteration short-circuit order are both preserved.
  • pkg/actionpins/actionpins_internal_test.go: The assert.Len + assert.True replacement is a correct, idiomatic alternative to the map[string]bool set pattern and validates the same invariant.

No correctness, security, or reliability issues found.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • proxy.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "proxy.golang.org"

See Network Configuration for more information.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 46.4 AIC · ⌖ 14.9 AIC · ⊞ 5.4K

@github-actions github-actions Bot 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.

Skills-Based Review 🧠

Applied /codebase-design and /tdd — commenting with two maintainability issues and one test-correctness concern.

📋 Key Themes & Highlights

Key Themes

  • 5-tuple return in collectConcatLoopAssignment — a struct would be cleaner and more idiomatic for analysis packages
  • Flag-setup fragmentationconfigureNewAndCompileFlags / configureCompileFlagsContinued / finalizeCompileFlagSetup have no semantic boundary; the split is arbitrary
  • Weakened test assertionassert.Len + assert.True is weaker than the removed assert.Equal and would miss spurious map entries

Positive Highlights

  • ✅ Excellent extraction of runCompileCmd — the compileCmdOptions struct + methods pattern is idiomatic and testable
  • rootUsageFunc / writeUsageCommands split is clean and semantically meaningful
  • shouldReportLoopConcat is a well-named predicate with a clear single responsibility
  • ✅ PR scope is tight: structural-only, no behaviour change

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 61.7 AIC · ⌖ 10.5 AIC · ⊞ 7.1K
Comment /matt to run again

if !astutil.IsStringType(pass, lhsExpr) {
continue
}
func collectConcatLoopAssignment(

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.

[/codebase-design] collectConcatLoopAssignment returns 5 values including multiple nils on every early-exit path. The 5-tuple return signature makes callers hard to read and the nil, nil, nil, token.Position{}, false noise obscures intent.

💡 Suggested improvement

Group into a small named struct:

type concatLoopMatch struct {
    assign   *ast.AssignStmt
    lhsExpr  ast.Expr
    loopNode ast.Node
    pos      token.Position
}

// Return (*concatLoopMatch, bool)
func collectConcatLoopAssignment(...) (*concatLoopMatch, bool)

This is a common Go pattern for analysis packages and removes the repeated nil, nil, nil, token.Position{}, false.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Introduced a concatLoopMatch struct grouping all four fields, and changed collectConcatLoopAssignment to return (*concatLoopMatch, bool). The multi-nil early exits are gone and the call site reads cleanly as m, ok := collectConcatLoopAssignment(...). Done in 882d0ea.


require.NotNil(t, ctx.Warnings, "Expected warnings map to remain initialized")
assert.Equal(t, expected, ctx.Warnings, "Expected existing warnings to be preserved unchanged")
assert.Len(t, ctx.Warnings, 1, "Expected existing warnings to be preserved unchanged")

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.

[/tdd] The new assertion checks Len + key presence, but the original test's intent was to verify the map is exactly {"actions/checkout@v5": true} — value and nothing else. The new form would pass if a second key was silently added, weakening the regression guard.

💡 Stronger alternative

Keep the structural check as a direct equality on the map contents:

assert.Equal(t, map[string]bool{"actions/checkout@v5": true}, ctx.Warnings)

The comment above said the expected variable was extracted to prevent shared-pointer aliasing — that concern is real, but using a fresh literal in the assert call achieves the same safety without the extra variable.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Replaced the two-step Len + True assertions with a single assert.Equal(t, map[string]bool{"actions/checkout@v5": true}, ctx.Warnings, ...), which catches both unexpected keys and wrong values. Done in 882d0ea.

Comment thread cmd/gh-aw/main.go Outdated
}

// Add flags to new command
func configureNewAndCompileFlags() {

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.

[/codebase-design] The flag setup for compileCmd is split across three functions (configureNewAndCompileFlags, configureCompileFlagsContinued, finalizeCompileFlagSetup) with no semantic distinction between them — the split appears driven purely by line-count rather than cohesion. Callers must know to call all three in sequence.

💡 Suggested improvement

Either merge into a single configureCompileFlags() (which is the natural single-responsibility boundary), or give the splits meaningful names that reflect what they configure (e.g., configureCompileInputFlags, configureCompileAnalysisFlags, finalizeCompileFlagConstraints). The current naming makes the sequence feel arbitrary.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Separated configureNewAndCompileFlags into configureNewCmdFlags (new-command flags only) and configureCompileBuildFlags (core compile options: engine, action pins, output control). Renamed configureCompileFlagsContinuedconfigureCompileToolFlags (scanner and analysis tool flags) and finalizeCompileFlagSetupfinalizeCompileFlags (mutual-exclusivity constraints and completions). The call site in init() now reflects the purpose of each step. Done in 882d0ea.

@github-actions github-actions Bot 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.

Review: mechanical refactor, no blocking issues found

Reviewed the full diff (cmd/gh-aw/main.go init/compile-cmd decomposition, stringsconcatloop analyzer split, actionpins test map-as-set removal) plus a background grumpy-coder pass. Both independently found no correctness regressions — flag wiring, group assignment, command registration, and the analyzer's control flow (assign→lhs extraction→loop/nolint gating→report) are preserved 1:1 across the extracted helpers.

💡 Notes (non-blocking)
  • commandSet groups fields on shared lines (e.g. addCmd, addWizardCmd, updateCmd, ...) which is a slightly unusual Go style but harmless.
  • A couple of explanatory comments were dropped during extraction (e.g. the "Non-fatal: flag is registered even if MarkHidden fails" comment on finalizeCompileFlagSetup), but behavior is unchanged.
  • No test coverage changes accompany the main.go restructuring, but since this file was previously untested at this granularity, that's consistent with the existing baseline.

🔎 Code quality review by PR Code Quality Reviewer · auto · 75.9 AIC · ⌖ 4.5 AIC · ⊞ 7.8K
Comment /review to run again

@pelikhan

pelikhan commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

… assertion, semantic flag naming

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan
pelikhan merged commit f3ec5bb into main Aug 2, 2026
29 checks passed
@pelikhan
pelikhan deleted the copilot/fix-leftover-golint-findings branch August 2, 2026 14:04
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.

[Code Quality] Fix leftover golint findings: cmd/gh-aw/main.go, stringsconcatloop, actionpins_internal_test

3 participants