mirror of
https://github.com/tiennm99/miti99bot.git
synced 2026-09-14 06:20:27 +00:00
fix(stats): resolve golangci-lint G118 and QF1001 violations
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user