chore: bump golangci-lint to the latest version (#9445)

This commit is contained in:
Pandey
2025-10-30 16:51:35 +05:30
committed by GitHub
parent 01e0b36d62
commit f8e0db0085
8 changed files with 73 additions and 59 deletions

View File

@@ -1,43 +1,63 @@
version: "2"
linters: linters:
default: standard default: none
enable: enable:
- bodyclose - bodyclose
- depguard
- errcheck
- forbidigo
- govet
- iface
- ineffassign
- misspell - misspell
- nilnil - nilnil
- sloglint - sloglint
- depguard
- iface
- unparam - unparam
- forbidigo - unused
settings:
linters-settings: depguard:
sloglint: rules:
no-mixed-args: true noerrors:
kv-only: true deny:
no-global: all - pkg: errors
context: all desc: Do not use errors package. Use github.com/SigNoz/signoz/pkg/errors instead.
static-msg: true nozap:
msg-style: lowercased deny:
key-naming-case: snake - pkg: go.uber.org/zap
depguard: desc: Do not use zap logger. Use slog instead.
rules: forbidigo:
nozap: forbid:
deny: - pattern: fmt.Errorf
- pkg: "go.uber.org/zap" - pattern: ^(fmt\.Print.*|print|println)$
desc: "Do not use zap logger. Use slog instead." iface:
noerrors: enable:
deny: - identical
- pkg: "errors" sloglint:
desc: "Do not use errors package. Use github.com/SigNoz/signoz/pkg/errors instead." no-mixed-args: true
iface: kv-only: true
enable: no-global: all
- identical context: all
forbidigo: static-msg: true
forbid: key-naming-case: snake
- fmt.Errorf exclusions:
- ^(fmt\.Print.*|print|println)$ generated: lax
issues: presets:
exclude-dirs: - comments
- "pkg/query-service" - common-false-positives
- "ee/query-service" - legacy
- "scripts/" - std-error-handling
paths:
- pkg/query-service
- ee/query-service
- scripts/
- tmp/
- third_party$
- builtin$
- examples$
formatters:
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$

View File

@@ -2,7 +2,6 @@ package alertmanagerbatcher
import ( import (
"context" "context"
"io"
"log/slog" "log/slog"
"testing" "testing"
@@ -11,7 +10,7 @@ import (
) )
func TestBatcherWithOneAlertAndDefaultConfigs(t *testing.T) { func TestBatcherWithOneAlertAndDefaultConfigs(t *testing.T) {
batcher := New(slog.New(slog.NewTextHandler(io.Discard, nil)), NewConfig()) batcher := New(slog.New(slog.DiscardHandler), NewConfig())
_ = batcher.Start(context.Background()) _ = batcher.Start(context.Background())
batcher.Add(context.Background(), &alertmanagertypes.PostableAlert{Alert: alertmanagertypes.AlertModel{ batcher.Add(context.Background(), &alertmanagertypes.PostableAlert{Alert: alertmanagertypes.AlertModel{
@@ -25,7 +24,7 @@ func TestBatcherWithOneAlertAndDefaultConfigs(t *testing.T) {
} }
func TestBatcherWithBatchSize(t *testing.T) { func TestBatcherWithBatchSize(t *testing.T) {
batcher := New(slog.New(slog.NewTextHandler(io.Discard, nil)), Config{Size: 2, Capacity: 4}) batcher := New(slog.New(slog.DiscardHandler), Config{Size: 2, Capacity: 4})
_ = batcher.Start(context.Background()) _ = batcher.Start(context.Background())
var alerts alertmanagertypes.PostableAlerts var alerts alertmanagertypes.PostableAlerts
@@ -45,7 +44,7 @@ func TestBatcherWithBatchSize(t *testing.T) {
} }
func TestBatcherWithCClosed(t *testing.T) { func TestBatcherWithCClosed(t *testing.T) {
batcher := New(slog.New(slog.NewTextHandler(io.Discard, nil)), Config{Size: 2, Capacity: 4}) batcher := New(slog.New(slog.DiscardHandler), Config{Size: 2, Capacity: 4})
_ = batcher.Start(context.Background()) _ = batcher.Start(context.Background())
var alerts alertmanagertypes.PostableAlerts var alerts alertmanagertypes.PostableAlerts

View File

@@ -2,14 +2,14 @@ package alertmanagerserver
import ( import (
"context" "context"
"github.com/SigNoz/signoz/pkg/types/alertmanagertypes/alertmanagertypestest"
"github.com/prometheus/alertmanager/dispatch"
"io"
"log/slog" "log/slog"
"net/http" "net/http"
"testing" "testing"
"time" "time"
"github.com/SigNoz/signoz/pkg/types/alertmanagertypes/alertmanagertypestest"
"github.com/prometheus/alertmanager/dispatch"
"github.com/SigNoz/signoz/pkg/alertmanager/nfmanager" "github.com/SigNoz/signoz/pkg/alertmanager/nfmanager"
"github.com/SigNoz/signoz/pkg/alertmanager/nfmanager/nfroutingstore/nfroutingstoretest" "github.com/SigNoz/signoz/pkg/alertmanager/nfmanager/nfroutingstore/nfroutingstoretest"
"github.com/SigNoz/signoz/pkg/alertmanager/nfmanager/rulebasednotification" "github.com/SigNoz/signoz/pkg/alertmanager/nfmanager/rulebasednotification"
@@ -89,7 +89,7 @@ func TestEndToEndAlertManagerFlow(t *testing.T) {
srvCfg := NewConfig() srvCfg := NewConfig()
stateStore := alertmanagertypestest.NewStateStore() stateStore := alertmanagertypestest.NewStateStore()
registry := prometheus.NewRegistry() registry := prometheus.NewRegistry()
logger := slog.New(slog.NewTextHandler(io.Discard, nil)) logger := slog.New(slog.DiscardHandler)
server, err := New(context.Background(), logger, registry, srvCfg, orgID, stateStore, notificationManager) server, err := New(context.Background(), logger, registry, srvCfg, orgID, stateStore, notificationManager)
require.NoError(t, err) require.NoError(t, err)
amConfig, err := alertmanagertypes.NewDefaultConfig(srvCfg.Global, srvCfg.Route, orgID) amConfig, err := alertmanagertypes.NewDefaultConfig(srvCfg.Global, srvCfg.Route, orgID)

View File

@@ -3,7 +3,6 @@ package alertmanagerserver
import ( import (
"bytes" "bytes"
"context" "context"
"io"
"log/slog" "log/slog"
"net" "net"
"net/http" "net/http"
@@ -26,7 +25,7 @@ import (
func TestServerSetConfigAndStop(t *testing.T) { func TestServerSetConfigAndStop(t *testing.T) {
notificationManager := nfmanagertest.NewMock() notificationManager := nfmanagertest.NewMock()
server, err := New(context.Background(), slog.New(slog.NewTextHandler(io.Discard, nil)), prometheus.NewRegistry(), NewConfig(), "1", alertmanagertypestest.NewStateStore(), notificationManager) server, err := New(context.Background(), slog.New(slog.DiscardHandler), prometheus.NewRegistry(), NewConfig(), "1", alertmanagertypestest.NewStateStore(), notificationManager)
require.NoError(t, err) require.NoError(t, err)
amConfig, err := alertmanagertypes.NewDefaultConfig(alertmanagertypes.GlobalConfig{}, alertmanagertypes.RouteConfig{GroupInterval: 1 * time.Minute, RepeatInterval: 1 * time.Minute, GroupWait: 1 * time.Minute}, "1") amConfig, err := alertmanagertypes.NewDefaultConfig(alertmanagertypes.GlobalConfig{}, alertmanagertypes.RouteConfig{GroupInterval: 1 * time.Minute, RepeatInterval: 1 * time.Minute, GroupWait: 1 * time.Minute}, "1")
@@ -38,7 +37,7 @@ func TestServerSetConfigAndStop(t *testing.T) {
func TestServerTestReceiverTypeWebhook(t *testing.T) { func TestServerTestReceiverTypeWebhook(t *testing.T) {
notificationManager := nfmanagertest.NewMock() notificationManager := nfmanagertest.NewMock()
server, err := New(context.Background(), slog.New(slog.NewTextHandler(io.Discard, nil)), prometheus.NewRegistry(), NewConfig(), "1", alertmanagertypestest.NewStateStore(), notificationManager) server, err := New(context.Background(), slog.New(slog.DiscardHandler), prometheus.NewRegistry(), NewConfig(), "1", alertmanagertypestest.NewStateStore(), notificationManager)
require.NoError(t, err) require.NoError(t, err)
amConfig, err := alertmanagertypes.NewDefaultConfig(alertmanagertypes.GlobalConfig{}, alertmanagertypes.RouteConfig{GroupInterval: 1 * time.Minute, RepeatInterval: 1 * time.Minute, GroupWait: 1 * time.Minute}, "1") amConfig, err := alertmanagertypes.NewDefaultConfig(alertmanagertypes.GlobalConfig{}, alertmanagertypes.RouteConfig{GroupInterval: 1 * time.Minute, RepeatInterval: 1 * time.Minute, GroupWait: 1 * time.Minute}, "1")
@@ -86,7 +85,7 @@ func TestServerPutAlerts(t *testing.T) {
srvCfg := NewConfig() srvCfg := NewConfig()
srvCfg.Route.GroupInterval = 1 * time.Second srvCfg.Route.GroupInterval = 1 * time.Second
notificationManager := nfmanagertest.NewMock() notificationManager := nfmanagertest.NewMock()
server, err := New(context.Background(), slog.New(slog.NewTextHandler(io.Discard, nil)), prometheus.NewRegistry(), srvCfg, "1", stateStore, notificationManager) server, err := New(context.Background(), slog.New(slog.DiscardHandler), prometheus.NewRegistry(), srvCfg, "1", stateStore, notificationManager)
require.NoError(t, err) require.NoError(t, err)
amConfig, err := alertmanagertypes.NewDefaultConfig(srvCfg.Global, srvCfg.Route, "1") amConfig, err := alertmanagertypes.NewDefaultConfig(srvCfg.Global, srvCfg.Route, "1")
@@ -134,7 +133,7 @@ func TestServerTestAlert(t *testing.T) {
srvCfg := NewConfig() srvCfg := NewConfig()
srvCfg.Route.GroupInterval = 1 * time.Second srvCfg.Route.GroupInterval = 1 * time.Second
notificationManager := nfmanagertest.NewMock() notificationManager := nfmanagertest.NewMock()
server, err := New(context.Background(), slog.New(slog.NewTextHandler(io.Discard, nil)), prometheus.NewRegistry(), srvCfg, "1", stateStore, notificationManager) server, err := New(context.Background(), slog.New(slog.DiscardHandler), prometheus.NewRegistry(), srvCfg, "1", stateStore, notificationManager)
require.NoError(t, err) require.NoError(t, err)
amConfig, err := alertmanagertypes.NewDefaultConfig(srvCfg.Global, srvCfg.Route, "1") amConfig, err := alertmanagertypes.NewDefaultConfig(srvCfg.Global, srvCfg.Route, "1")
@@ -239,7 +238,7 @@ func TestServerTestAlertContinuesOnFailure(t *testing.T) {
srvCfg := NewConfig() srvCfg := NewConfig()
srvCfg.Route.GroupInterval = 1 * time.Second srvCfg.Route.GroupInterval = 1 * time.Second
notificationManager := nfmanagertest.NewMock() notificationManager := nfmanagertest.NewMock()
server, err := New(context.Background(), slog.New(slog.NewTextHandler(io.Discard, nil)), prometheus.NewRegistry(), srvCfg, "1", stateStore, notificationManager) server, err := New(context.Background(), slog.New(slog.DiscardHandler), prometheus.NewRegistry(), srvCfg, "1", stateStore, notificationManager)
require.NoError(t, err) require.NoError(t, err)
amConfig, err := alertmanagertypes.NewDefaultConfig(srvCfg.Global, srvCfg.Route, "1") amConfig, err := alertmanagertypes.NewDefaultConfig(srvCfg.Global, srvCfg.Route, "1")

View File

@@ -2,7 +2,6 @@ package factory
import ( import (
"context" "context"
"io"
"log/slog" "log/slog"
"sync" "sync"
"testing" "testing"
@@ -33,7 +32,7 @@ func TestRegistryWith2Services(t *testing.T) {
s1 := newTestService(t) s1 := newTestService(t)
s2 := newTestService(t) s2 := newTestService(t)
registry, err := NewRegistry(slog.New(slog.NewTextHandler(io.Discard, nil)), NewNamedService(MustNewName("s1"), s1), NewNamedService(MustNewName("s2"), s2)) registry, err := NewRegistry(slog.New(slog.DiscardHandler), NewNamedService(MustNewName("s1"), s1), NewNamedService(MustNewName("s2"), s2))
require.NoError(t, err) require.NoError(t, err)
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
@@ -54,7 +53,7 @@ func TestRegistryWith2ServicesWithoutWait(t *testing.T) {
s1 := newTestService(t) s1 := newTestService(t)
s2 := newTestService(t) s2 := newTestService(t)
registry, err := NewRegistry(slog.New(slog.NewTextHandler(io.Discard, nil)), NewNamedService(MustNewName("s1"), s1), NewNamedService(MustNewName("s2"), s2)) registry, err := NewRegistry(slog.New(slog.DiscardHandler), NewNamedService(MustNewName("s1"), s1), NewNamedService(MustNewName("s2"), s2))
require.NoError(t, err) require.NoError(t, err)
ctx := context.Background() ctx := context.Background()

View File

@@ -1,7 +1,6 @@
package middleware package middleware
import ( import (
"io"
"log/slog" "log/slog"
"net" "net"
"net/http" "net/http"
@@ -17,7 +16,7 @@ func TestTimeout(t *testing.T) {
writeTimeout := 6 * time.Second writeTimeout := 6 * time.Second
defaultTimeout := 2 * time.Second defaultTimeout := 2 * time.Second
maxTimeout := 4 * time.Second maxTimeout := 4 * time.Second
m := NewTimeout(slog.New(slog.NewTextHandler(io.Discard, nil)), []string{"/excluded"}, defaultTimeout, maxTimeout) m := NewTimeout(slog.New(slog.DiscardHandler), []string{"/excluded"}, defaultTimeout, maxTimeout)
listener, err := net.Listen("tcp", "localhost:0") listener, err := net.Listen("tcp", "localhost:0")
require.NoError(t, err) require.NoError(t, err)

View File

@@ -1,7 +1,6 @@
package instrumentationtest package instrumentationtest
import ( import (
"io"
"log/slog" "log/slog"
"github.com/SigNoz/signoz/pkg/factory" "github.com/SigNoz/signoz/pkg/factory"
@@ -21,7 +20,7 @@ type noopInstrumentation struct {
func New() instrumentation.Instrumentation { func New() instrumentation.Instrumentation {
return &noopInstrumentation{ return &noopInstrumentation{
logger: slog.New(slog.NewTextHandler(io.Discard, nil)), logger: slog.New(slog.DiscardHandler),
meterProvider: noopmetric.NewMeterProvider(), meterProvider: noopmetric.NewMeterProvider(),
tracerProvider: nooptrace.NewTracerProvider(), tracerProvider: nooptrace.NewTracerProvider(),
} }

View File

@@ -2,7 +2,6 @@ package signoz
import ( import (
"context" "context"
"io"
"log/slog" "log/slog"
"testing" "testing"
@@ -13,7 +12,7 @@ import (
// This is a test to ensure that all fields of config implement the factory.Config interface and are valid with // This is a test to ensure that all fields of config implement the factory.Config interface and are valid with
// their default values. // their default values.
func TestValidateConfig(t *testing.T) { func TestValidateConfig(t *testing.T) {
logger := slog.New(slog.NewTextHandler(io.Discard, nil)) logger := slog.New(slog.DiscardHandler)
_, err := NewConfig(context.Background(), logger, configtest.NewResolverConfig(), DeprecatedFlags{}) _, err := NewConfig(context.Background(), logger, configtest.NewResolverConfig(), DeprecatedFlags{})
assert.NoError(t, err) assert.NoError(t, err)
} }