Skip to content

Refactor two parameter-heavy functions to satisfy custom lint parameter-count limits - #52817

Closed
pelikhan with Copilot wants to merge 4 commits into
mainfrom
copilot/lint-monster-refactor-parameters
Closed

Refactor two parameter-heavy functions to satisfy custom lint parameter-count limits#52817
pelikhan with Copilot wants to merge 4 commits into
mainfrom
copilot/lint-monster-refactor-parameters

Conversation

Copilot AI commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

make golint-custom flagged two functions at 9 parameters (limit 8): EnforceSafeUpdate and resolveRepositoryPackageExtensionFiles. This change reduces each signature with minimal surface-area refactors while preserving existing behavior and call flow.

  • Safe update enforcement: collapse event/redirect/script inputs into options

    • Introduced SafeUpdateEnforcementOptions in pkg/workflow/safe_update_enforcement.go.
    • Updated EnforceSafeUpdate(...) to take the options struct instead of multiple scalar parameters.
    • Updated compiler and workflow tests to pass the new structured argument.
  • Repository package extension resolution: group repository location inputs

    • Introduced repositoryPackageLocation in pkg/cli/add_package_manifest.go.
    • Updated resolveRepositoryPackageExtensionFiles(...) to accept the location struct instead of separate owner/repo/path/ref/host args.
    • Updated the single call site in package resolution flow.
  • Scope discipline

    • Changes are limited to the two lint findings and direct call-site/test adaptations; no broader API redesign or logic rewrite.
// before
err := EnforceSafeUpdate(manifest, secrets, actions, redirect, oldPR, oldPRTarget, curPR, curPRTarget, scripts)

// after
err := EnforceSafeUpdate(manifest, secrets, actions, SafeUpdateEnforcementOptions{
    CurrentRedirect:                redirect,
    OldHasPullRequest:              oldPR,
    OldHasPullRequestTarget:        oldPRTarget,
    CurrentHasPullRequest:          curPR,
    CurrentHasPullRequestTarget:    curPRTarget,
    CurrentMemoryValidationScripts: scripts,
})

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 19.6 AIC · ⌖ 7.98 AIC · ⊞ 8.7K ·
Comment /souschef to run again

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor functions to reduce parameter count Refactor two parameter-heavy functions to satisfy custom lint parameter-count limits Aug 15, 2026
Copilot AI requested a review from pelikhan August 15, 2026 03:01
@pelikhan
pelikhan marked this pull request as ready for review August 15, 2026 04:58
Copilot AI balanced review requested due to automatic review settings August 15, 2026 04:58
@github-actions

github-actions Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

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

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Aug 15, 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 only 60 new lines of code in business logic directories (threshold: 100).

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Ponytail Reviewer completed successfully!

Lean already. Ship. Diff is a minimal, mechanical fix for golint-custom's parameter-count limit: two >8-param functions were collapsed into single-purpose options structs (SafeUpdateEnforcementOptions, repositoryPackageLocation), each with exactly one call site and no speculative fields. This is the standard idiomatic Go pattern for excess parameters, not over-engineering. No dead code, reinvented stdlib, or unneeded abstractions found.

Generated by Ponytail Reviewer for #52817

@github-actions

github-actions Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

Completed PR review; no actionable blocking issues were found in the changed lines, so no PR comments or review submission were necessary.

🔎 Code quality review by PR Code Quality Reviewer

@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.

Clean refactor — no logic changes, just grouping parameters into structs to satisfy lint limits. All call sites updated consistently. LGTM.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 13.5 AIC · ⌖ 6.99 AIC · ⊞ 5.4K

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 two parameter-heavy functions to satisfy lint limits without changing behavior.

Changes:

  • Groups safe-update inputs into an options struct.
  • Groups repository location inputs into a location struct.
  • Updates affected callers and tests.
Show a summary per file
File Description
pkg/workflow/safe_update_enforcement.go Adds safe-update options and updates enforcement logic.
pkg/workflow/safe_update_enforcement_test.go Adapts safe-update tests.
pkg/workflow/compiler.go Passes structured enforcement options.
pkg/workflow/compiler_threat_detection_formal_test.go Adapts formal threat-detection tests.
pkg/cli/add_package_manifest.go Groups repository location parameters.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread pkg/workflow/safe_update_enforcement.go Outdated
//
// Returns a structured, actionable error when violations are found.
func EnforceSafeUpdate(manifest *GHAWManifest, secretNames []string, actionRefs []string, currentRedirect string, oldHasPullRequest bool, oldHasPullRequestTarget bool, currentHasPullRequest bool, currentHasPullRequestTarget bool, currentMemoryValidationScripts []GHAWManifestMemoryValidationScript) error {
type SafeUpdateEnforcementOptions struct {

@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 — approving with one minor suggestion.

📋 Key Themes & Highlights

Positive Highlights

  • SafeUpdateEnforcementOptions cleanly groups the six boolean/string PR-context params — zero ambiguity at call sites
  • repositoryPackageLocation is unexported (correctly scoped to the cli package), consistent with the existing repositoryPackageExtensionFiles pattern
  • ✅ All call sites and formal tests updated; behaviour-preserving refactor with good scope discipline
  • ✅ Test file changes are pure mechanical substitutions — no coverage is lost

One minor suggestion

  • SafeUpdateEnforcementOptions is exported but undocumented; a short GoDoc comment on the type and its boolean fields would help reviewers understand the before/after semantics (see inline comment).

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 29.6 AIC · ⌖ 8.79 AIC · ⊞ 7K
Comment /matt to run again

Comment thread pkg/workflow/safe_update_enforcement.go Outdated
CurrentRedirect string
OldHasPullRequest bool
OldHasPullRequestTarget bool
CurrentHasPullRequest bool

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] SafeUpdateEnforcementOptions is exported and used in security-sensitive enforcement logic, but has no GoDoc comment — new contributors need to understand what the boolean fields guard against without diving into the implementation.

💡 Suggested doc comment
// SafeUpdateEnforcementOptions carries the per-compilation context needed by
// EnforceSafeUpdate to detect unsafe changes to pull-request event triggers,
// redirects, and memory-validation scripts relative to the existing manifest.
type SafeUpdateEnforcementOptions struct {
    // CurrentRedirect is the redirect value from the current workflow frontmatter.
    CurrentRedirect string
    // OldHasPullRequest reports whether the previous manifest triggered on pull_request events.
    OldHasPullRequest bool
    ...
}

@copilot please address this.

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

Test Quality Score: 100/100 — Excellent

Analyzed 13 test(s) (modified, no new functions): 13 design, 0 implementation, 0 violation(s).

📊 Metrics (13 modified tests)
Metric Value
Analyzed 13 (Go: 13, JS: 0)
✅ Design 13 (100%)
⚠️ Implementation 0 (0%)
Edge/error coverage 13 (100%)
Duplicate clusters 0
Inflation No
🚨 Violations 0
Test File Classification Issues
TestFormal_CTR016_* (×11) compiler_threat_detection_formal_test.go design_test · high_value None
TestEnforceSafeUpdate safe_update_enforcement_test.go design_test · high_value None
TestMemoryValidationScriptChangesRequireSafeUpdateReview safe_update_enforcement_test.go design_test · high_value None

Verdict

Passed. This PR is a pure call-site refactor — positional boolean parameters replaced with SafeUpdateEnforcementOptions{} struct. All 13 modified tests are design_test (CTR016 / safe-update security controls), retain their full behavioral assertions, and have no violations. Both files have correct (go/redacted):build !integration tags. 0% implementation tests (threshold: 30%).

🧪 Test quality analysis by Test Quality Sentinel · sonnet46 · 36.4 AIC · ⌖ 8.54 AIC · ⊞ 7.6K ·
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: 100/100. 0% implementation tests (threshold: 30%). Pure call-site refactor — all 13 modified tests retain full behavioral coverage with no violations.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Quick triage for maintainer-ready follow-up:

Please refresh the branch if needed, address the remaining maintainer-facing follow-up, and run the pr-finisher skill before handing this PR back to maintainers.

Outstanding review items (newest first):

  • No unresolved review threads were available from the compact context; please verify the current branch and maintainer expectations before handoff.

Failed checks from the compact candidate set:

  • None listed.

Branch update was requested automatically for this run when GitHub allows it.
Run context: https://github.com/github/gh-aw/actions/runs/31867777089

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 33.2 AIC · ⌖ 5.85 AIC · ⊞ 8.7K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Quick triage for maintainer-ready follow-up:

Please refresh the branch if needed, address the remaining maintainer-facing follow-up, and run the pr-finisher skill before handing this PR ba...

Addressed and pushed in 027d64d3ba.

  • Verified current PR review thread/check context and triaged the referenced run.
  • Applied the maintainer-facing follow-up in pkg/workflow/safe_update_enforcement.go (restored EnforceSafeUpdate doc-comment attachment and added GoDoc for SafeUpdateEnforcementOptions).
  • Ran local validation (make fmt, targeted workflow tests, and final make agent-report-progress).
  • Ran code_review and codeql_checker (trivial-change path).

@github-actions

Copy link
Copy Markdown
Contributor

PR Triage

Category: refactor | Risk: low | Score: 65/100

  • Impact: 15/50 (lint-only, no behavior change)
  • Urgency: 17/30 (unblocks golint-custom CI gate)
  • Quality: 18/20 (fully APPROVED, minimal diff)

Recommended action: auto_merge
Pure parameter-count lint fix, fully approved. Batched with #52614 (lint-cleanup-cluster) for auto-merge once CI confirms green.

Generated by 🔧 PR Triage Agent · auto · 46.6 AIC · ⌖ 2.63 AIC · ⊞ 8.1K ·

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Quick triage for maintainer-ready follow-up:

Please refresh the branch if needed, address the remaining maintainer-facing follow-up, and run the pr-finisher skill before handing this PR back to maintainers.

Outstanding review items (newest first):

  • confirm the latest doc-comment follow-up fully satisfies maintainer expectations and that the branch is ready for handoff
  • refresh the branch if GitHub indicates it is behind before running pr-finisher

Failed checks from the compact candidate set:

  • None listed.

Branch update was requested automatically for this run when GitHub allows it.
Run context: https://github.com/github/gh-aw/actions/runs/31870657040

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 14.7 AIC · ⌖ 7.13 AIC · ⊞ 6.3K ·
Comment /souschef to run again

Copilot AI commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Quick triage for maintainer-ready follow-up:

Please refresh the branch if needed, address the remaining maintainer-facing follow-up, and run the pr-finisher skill before handing this PR ba...

Confirmed on current PR state: the doc-comment follow-up in 027d64d is present in pkg/workflow/safe_update_enforcement.go and matches the requested contract/comment attachment.

Branch refresh is not required from current GitHub PR state (not indicated as behind).

Also re-triaged the referenced run (31870657040) and checked failed-job logs: no failed jobs were reported.

@github-actions

Copy link
Copy Markdown
Contributor

PR Triage

  • Category: refactor
  • Risk: low
  • Priority: medium
  • Score: 39/100
  • Recommended action: auto_merge
  • Batch: lint-cleanup-cluster

Pure parameter-count lint fix, no behavior change. CI passing. Good auto-merge candidate.

Automated triage — see [PR Triage Report] for full context.

Generated by 🔧 PR Triage Agent · auto · 62.5 AIC · ⌖ 2.53 AIC · ⊞ 8.1K ·

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Quick triage for maintainer-ready follow-up:

Please refresh the branch if needed, address the remaining maintainer-facing follow-up, and run the pr-finisher skill before handing this PR back to maintainers.

Outstanding review items (newest first):

Failed checks from the compact candidate set:

  • None listed.

Branch update was requested automatically for this run when GitHub allows it.
Run context: https://github.com/github/gh-aw/actions/runs/31885005799

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 19.6 AIC · ⌖ 7.98 AIC · ⊞ 8.7K ·
Comment /souschef to run again

Copilot AI commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Quick triage for maintainer-ready follow-up:

Please refresh the branch if needed, address the remaining maintainer-facing follow-up, and run the pr-finisher skill before handing this PR ba...

Triaged on the current branch head (fa09a15). The two linked review threads are already addressed in pkg/workflow/safe_update_enforcement.go (EnforceSafeUpdate doc comment attached to the function and SafeUpdateEnforcementOptions has its own GoDoc), and both threads are now outdated.

Branch refresh is not indicated from current PR state, and re-checking the referenced run (31885005799) shows no failed jobs.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts on this branch.

@pelikhan pelikhan closed this Aug 15, 2026
Copilot stopped work on behalf of pelikhan due to an error August 15, 2026 13:42
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] LintMonster: parameter-count options-struct follow-ups (2 findings)

4 participants