[hermes] ananke #68: go:S107 #8

Open
opened 2026-08-07 08:19:13 +00:00 by bstein · 0 comments
Owner

Hermes auto-triage classified incident sonar/ananke/go:S107/AZ4tzXzmqCRMjDT4d-fU as go:S107 (confidence n/a); first failed gate: unknown.

Why a human is needed

TestHookMaybeStartGitOpsSnapshotWithRunner has eight independent parameters solely to expose a test seam, exceeding the configured parameter limit. Grouping its related dependencies and scrape state into a request struct preserves the exact call path and asynchronous runner-restoration behavior.

Ariadne did not authorize automated remediation: no automated patch was possible for this finding.

Facts

  • gitea — This function has 8 parameters, which is greater than the 7 authorized. (MAJOR, 20min estimated) (internal/service/testing_hooks_gitops.go:68)

Suggested fix (not applied)

Hermes could not open a pull request for this, so the change below was not written, validated, or pushed anywhere. It is a starting point for whoever picks this up, not a reviewed patch.

internal/service/testing_hooks_gitops.go — Replace the eight-parameter test hook with a context plus a typed request struct. This keeps every value and control-flow branch unchanged while making the hook easier for tests to construct and satisfying go:S107.

type TestHookMaybeStartGitOpsSnapshotWithRunnerRequest struct {
	Config    config.Config
	Exporter  *metrics.Exporter
	Logger    *log.Logger
	LastRun   *time.Time
	Running   bool
	Done      chan<- struct{}
	Runner    TestHookGitOpsRunner
}

// TestHookMaybeStartGitOpsSnapshotWithRunner starts a background GitOps scrape
// with an injected runner and restores the production runner after completion.
func TestHookMaybeStartGitOpsSnapshotWithRunner(ctx context.Context, request TestHookMaybeStartGitOpsSnapshotWithRunnerRequest) bool {
	original := gitOpsKubectlOutput
	gitOpsKubectlOutput = request.Runner
	proxyDone := make(chan struct{}, 1)
	d := &Daemon{cfg: request.Config, exporter: request.Exporter, log: request.Logger}
	started := d.maybeStartGitOpsSnapshot(ctx, request.LastRun, request.Running, proxyDone)
	if !started || request.Running {
		gitOpsKubectlOutput = original
		return started
	}
	go func() {
		<-proxyDone
		gitOpsKubectlOutput = original
		select {
		case request.Done <- struct{}{}:
		default:
		}
	}()
	return started
}

Filed automatically by Ariadne from a Hermes Agent diagnosis (run run_312124bcc7ea47b0874fd72bbce4c1cf). Hermes has no write access to this repository; no files or infrastructure were changed.

Hermes auto-triage classified incident `sonar/ananke/go:S107/AZ4tzXzmqCRMjDT4d-fU` as **go:S107** (confidence n/a); first failed gate: `unknown`. ## Why a human is needed TestHookMaybeStartGitOpsSnapshotWithRunner has eight independent parameters solely to expose a test seam, exceeding the configured parameter limit. Grouping its related dependencies and scrape state into a request struct preserves the exact call path and asynchronous runner-restoration behavior. Ariadne did not authorize automated remediation: `no automated patch was possible for this finding`. ## Facts - **gitea** — This function has 8 parameters, which is greater than the 7 authorized. (MAJOR, 20min estimated) (`internal/service/testing_hooks_gitops.go:68`) ## Suggested fix (not applied) Hermes could not open a pull request for this, so the change below was not written, validated, or pushed anywhere. It is a starting point for whoever picks this up, not a reviewed patch. **`internal/service/testing_hooks_gitops.go`** — Replace the eight-parameter test hook with a context plus a typed request struct. This keeps every value and control-flow branch unchanged while making the hook easier for tests to construct and satisfying go:S107. ``` type TestHookMaybeStartGitOpsSnapshotWithRunnerRequest struct { Config config.Config Exporter *metrics.Exporter Logger *log.Logger LastRun *time.Time Running bool Done chan<- struct{} Runner TestHookGitOpsRunner } // TestHookMaybeStartGitOpsSnapshotWithRunner starts a background GitOps scrape // with an injected runner and restores the production runner after completion. func TestHookMaybeStartGitOpsSnapshotWithRunner(ctx context.Context, request TestHookMaybeStartGitOpsSnapshotWithRunnerRequest) bool { original := gitOpsKubectlOutput gitOpsKubectlOutput = request.Runner proxyDone := make(chan struct{}, 1) d := &Daemon{cfg: request.Config, exporter: request.Exporter, log: request.Logger} started := d.maybeStartGitOpsSnapshot(ctx, request.LastRun, request.Running, proxyDone) if !started || request.Running { gitOpsKubectlOutput = original return started } go func() { <-proxyDone gitOpsKubectlOutput = original select { case request.Done <- struct{}{}: default: } }() return started } ``` ## Links - Failed build: https://quality.bstein.dev/project/issues?resolved=false&id=ananke&open=AZ4tzXzmqCRMjDT4d-fU - Full evidence bundle and audit trail live in Ariadne at `/api/admin/audit/events`, event types `hermes_autotriage_incident` and `hermes_autotriage_diagnosis`. Filed automatically by Ariadne from a Hermes Agent diagnosis (run [run_312124bcc7ea47b0874fd72bbce4c1cf](https://agent.bstein.dev/chat?resume=run_312124bcc7ea47b0874fd72bbce4c1cf)). Hermes has no write access to this repository; no files or infrastructure were changed. <!-- hermes-triage job=ananke classification=go:S107 incident=sonar/ananke/go:S107/AZ4tzXzmqCRMjDT4d-fU -->
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: titan/ananke#8
No description provided.