[hermes] soteria: go:S3776 #46
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 (internal/server/metrics.go:133) has cognitive complexity 16 because the per-PVC metric logic — the reason-defaulting if, the healthy/unhealthy if/else, the empty-LastBackupAt guard, and the parseBackupTime if — is all written inline inside a doubly-nested for loop (namespace -> pvc), so every branch inside picks up two extra nesting increments.
Ariadne opened no pull request for it: no automated patch was possible for this finding.
Facts
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— Extract the per-PVC branch logic into its own method, recordPVCMetric. This doesn't change any behavior (same maps, same labels, same values, same order of operations) but moves the four conditional branches out of the doubly-nested loop into a top-level method with nesting depth 0, dropping RecordInventory's cognitive complexity to just the two for loops (well under 15) and keeping the extracted method's own complexity low too. Adjust the parameter type to whatever the actual element type of namespace.PVCs is in this codebase (shown here as api.PVCInventory to match the api.InventoryResponse/... (truncated)
Links
/api/admin/audit/events, event typeshermes_autotriage_incidentandhermes_autotriage_diagnosis.Filed automatically by Ariadne from a Hermes Agent diagnosis (run run_ef3fd691f4da4ffcbf1f40c3e3f15f06). Hermes has no write access to this repository; no files or infrastructure were changed.