[hermes] soteria: go:S3776 #90

Open
opened 2026-10-25 12:25:37 +00:00 by hermes-automation · 0 comments

SonarQube reports go:S3776 in internal/server/metrics.go. The build is green; this is a standing finding, not a failure.

What is wrong

RecordInventory exceeds the allowed Cognitive Complexity because its nested PVC loop contains several conditional branches. Converting the Healthy boolean through a small helper removes one branch from the method without changing the emitted metric values.

Ariadne opened no pull request for it: no automated patch was possible for this finding.

Facts

  • gitea — Refactor this method to reduce its Cognitive Complexity from 16 to the 15 allowed. (CRITICAL, 6min estimated) (internal/server/metrics.go:133)

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/server/metrics.go — Replace the if/else that maps pvc.Healthy to 1 or 0 with a helper call. This preserves the exact metric behavior while reducing RecordInventory's Cognitive Complexity below the configured limit.

// In RecordInventory, replace the pvc.Healthy conditional with:
setMetric(t.pvcBackupHealth, labels, metricValue(pvc.Healthy))

// Add this helper near the other metric helpers:
func metricValue(condition bool) float64 {
	if condition {
		return 1
	}
	return 0
}

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

SonarQube reports **go:S3776** in `internal/server/metrics.go`. The build is green; this is a standing finding, not a failure. ## What is wrong RecordInventory exceeds the allowed Cognitive Complexity because its nested PVC loop contains several conditional branches. Converting the Healthy boolean through a small helper removes one branch from the method without changing the emitted metric values. Ariadne opened no pull request for it: no automated patch was possible for this finding. ## Facts - **gitea** — Refactor this method to reduce its Cognitive Complexity from 16 to the 15 allowed. (CRITICAL, 6min estimated) (`internal/server/metrics.go:133`) ## 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/server/metrics.go`** — Replace the if/else that maps pvc.Healthy to 1 or 0 with a helper call. This preserves the exact metric behavior while reducing RecordInventory's Cognitive Complexity below the configured limit. ``` // In RecordInventory, replace the pvc.Healthy conditional with: setMetric(t.pvcBackupHealth, labels, metricValue(pvc.Healthy)) // Add this helper near the other metric helpers: func metricValue(condition bool) float64 { if condition { return 1 } return 0 } ``` ## Links - SonarQube finding: https://quality.bstein.dev/project/issues?resolved=false&id=soteria&open=AZ4WREVmqCRMjDT4bXbu - 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_4fba471be1c842d99c3d5ed0f84c203a](https://triage.bstein.dev/chat?resume=run_4fba471be1c842d99c3d5ed0f84c203a)). Hermes has no write access to this repository; no files or infrastructure were changed. <!-- hermes-triage job=soteria classification=go:S3776 incident=sonar/soteria/go:S3776/AZ4WREVmqCRMjDT4bXbu -->
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: titan/soteria#90
No description provided.