@cryptotaxi247 / netdata / commits / 7a8ac3abd

Fix based on Coverity and Sonar audits (part 7) (#22335)

* go.d/rethinkdb: drop degenerate switch in sortRethinkRows Sonar go:S3923: sortRethinkRows() switched on sortColumn but the "durationMs" case and the default branch performed the same descending sort by DurationMs. RethinkDB only exposes durationMs as a server-side sort option (the only column with sortOpt: true in rethinkRunningColumns), so the switch was always going to take one of two identical paths. Drop the switch and sort directly. The unused parameter is renamed to `_` (Go idiom). Behaviour and call shape are unchanged. * Only durationMs is exposed as a sort option, so the function hard-codes the order. Remove the now-unused parameter rather than leaving a stub that suggests sorting is configurable. --------- Co-authored-by: Costa Tsaousis <costa@netdata.cloud>

Stelios Fragkakis committed May 7, 2026 at 19:51 UTC 7a8ac3abd22537858be7f0dd6aa702273f5d6bd3
1 file changed +3 -8
src/go/plugin/go.d/collector/rethinkdb/func_running_queries.go
+3 -8
@@ -106,7 +106,7 @@ func (f *funcRunningQueries) collectRunningQueries(ctx context.Context, sortColu
106 }
107
108 sortColumn = mapRethinkSortColumn(sortColumn)
109 - sortRethinkRows(jobRows, sortColumn)
109 + sortRethinkRows(jobRows)
110 if len(jobRows) > limit {
111 jobRows = jobRows[:limit]
112 }
@@ -275,11 +275,6 @@ func mapRethinkSortColumn(input string) string {
275 return ""
276 }
277
278 -func sortRethinkRows(rows []rethinkJobRow, sortColumn string) {
279 - switch sortColumn {
280 - case "durationMs":
281 - sort.Slice(rows, func(i, j int) bool { return rows[i].DurationMs > rows[j].DurationMs })
282 - default:
283 - sort.Slice(rows, func(i, j int) bool { return rows[i].DurationMs > rows[j].DurationMs })
284 - }
278 +func sortRethinkRows(rows []rethinkJobRow) {
279 + sort.Slice(rows, func(i, j int) bool { return rows[i].DurationMs > rows[j].DurationMs })
280 }