fix(stats): resolve golangci-lint G118 and QF1001 violations

This commit is contained in:
2026-05-22 15:10:26 +07:00
parent cb319626f3
commit 5717d73e5c
2 changed files with 4 additions and 1 deletions
+3
View File
@@ -68,6 +68,9 @@ func Install(b *bot.Bot, reg *Registry, auth Auth) {
}
metrics.IncCommand(cmdCopy.Name)
go func() {
// context.Background is intentional: the hook must outlive the request
// context so stats writes complete even after the handler returns.
//nolint:gosec // G118: goroutine intentionally detached from request context
hookCtx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
reg.RunCommandHooks(hookCtx, cmdCopy.Name)
+1 -1
View File
@@ -110,7 +110,7 @@ func TestStats_ShowsCountsSortedByPopularity(t *testing.T) {
if wordlePos < 0 || loLdlePos < 0 || pingPos < 0 {
t.Fatalf("reply missing expected commands: %q", got)
}
if !(wordlePos < loLdlePos && loLdlePos < pingPos) {
if wordlePos >= loLdlePos || loLdlePos >= pingPos {
t.Errorf("commands not in descending count order: wordle=%d loldle=%d ping=%d in %q",
wordlePos, loLdlePos, pingPos, got)
}