[hermes] soteria: go:S3776 #9

Open
opened 2026-08-13 05:21:49 +00:00 by bstein · 0 comments
Owner

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 cognitive-complexity threshold by one point because it branches solely to translate pvc.Healthy into a metric value. Replace that branch with a small boolean-to-gauge helper without changing emitted metrics.

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 — The Healthy if/else writes the same metric with only the numeric value changed. Moving that boolean conversion to a helper removes one decision from RecordInventory while preserving the exact 1 for healthy and 0 for unhealthy behavior.

// In RecordInventory, replace:
if pvc.Healthy {
	setMetric(t.pvcBackupHealth, labels, 1)
} else {
	setMetric(t.pvcBackupHealth, labels, 0)
}

// with:
setMetric(t.pvcBackupHealth, labels, boolGauge(pvc.Healthy))

// Add near the other metric helpers:
func boolGauge(value bool) float64 {
	if value {
		return 1
	}
	return 0
}

Filed automatically by Ariadne from a Hermes Agent diagnosis (run run_8782f654008a48fbb30aea71acd65d87). 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 cognitive-complexity threshold by one point because it branches solely to translate pvc.Healthy into a metric value. Replace that branch with a small boolean-to-gauge helper without changing emitted metrics. 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`** — The Healthy if/else writes the same metric with only the numeric value changed. Moving that boolean conversion to a helper removes one decision from RecordInventory while preserving the exact 1 for healthy and 0 for unhealthy behavior. ``` // In RecordInventory, replace: if pvc.Healthy { setMetric(t.pvcBackupHealth, labels, 1) } else { setMetric(t.pvcBackupHealth, labels, 0) } // with: setMetric(t.pvcBackupHealth, labels, boolGauge(pvc.Healthy)) // Add near the other metric helpers: func boolGauge(value bool) float64 { if value { 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_8782f654008a48fbb30aea71acd65d87](https://triage.hermes.bstein.dev/chat?resume=run_8782f654008a48fbb30aea71acd65d87)). 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#9
No description provided.