diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index d4700ea415e1..323164f024c9 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -1982,6 +1982,9 @@ linters-settings: # Enforce using key-value pairs only (overrides no-mixed-args, incompatible with attr-only). # Default: false kv-only: true + # Enforce not using global loggers. + # Default: default + no-global: all # Enforce using attributes only (overrides no-mixed-args, incompatible with kv-only). # Default: false attr-only: true diff --git a/go.mod b/go.mod index d91b709b5def..afc352b0c7f5 100644 --- a/go.mod +++ b/go.mod @@ -117,7 +117,7 @@ require ( github.com/ykadowak/zerologlint v0.1.5 gitlab.com/bosi/decorder v0.4.1 go-simpler.org/musttag v0.9.0 - go-simpler.org/sloglint v0.4.0 + go-simpler.org/sloglint v0.5.0 go.uber.org/automaxprocs v1.5.3 golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc golang.org/x/tools v0.19.0 diff --git a/go.sum b/go.sum index ce18f429b272..023a103d512b 100644 --- a/go.sum +++ b/go.sum @@ -586,8 +586,8 @@ go-simpler.org/assert v0.7.0 h1:OzWWZqfNxt8cLS+MlUp6Tgk1HjPkmgdKBq9qvy8lZsA= go-simpler.org/assert v0.7.0/go.mod h1:74Eqh5eI6vCK6Y5l3PI8ZYFXG4Sa+tkr70OIPJAUr28= go-simpler.org/musttag v0.9.0 h1:Dzt6/tyP9ONr5g9h9P3cnYWCxeBFRkd0uJL/w+1Mxos= go-simpler.org/musttag v0.9.0/go.mod h1:gA9nThnalvNSKpEoyp3Ko4/vCX2xTpqKoUtNqXOnVR4= -go-simpler.org/sloglint v0.4.0 h1:UVJuUJo63iNQNFEOtZ6o1xAgagVg/giVLLvG9nNLobI= -go-simpler.org/sloglint v0.4.0/go.mod h1:v6zJ++j/thFPhefs2wEXoCKwT10yo5nkBDYRCXyqgNQ= +go-simpler.org/sloglint v0.5.0 h1:2YCcd+YMuYpuqthCgubcF5lBSjb6berc5VMOYUHKrpY= +go-simpler.org/sloglint v0.5.0/go.mod h1:EUknX5s8iXqf18KQxKnaBHUPVriiPnOrPjjJcsaTcSQ= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index ae76581ca469..0b1b582e2f17 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -2284,6 +2284,11 @@ "type": "boolean", "default": false }, + "no-global": { + "description": "Enforce not using global loggers.", + "enum": ["all", "default"], + "default": "default" + }, "no-mixed-args": { "description": "Enforce not mixing key-value pairs and attributes.", "type": "boolean", diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 484ce0cc0018..2c4358d9d0c3 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -793,6 +793,7 @@ type RowsErrCheckSettings struct { type SlogLintSettings struct { NoMixedArgs bool `mapstructure:"no-mixed-args"` KVOnly bool `mapstructure:"kv-only"` + NoGlobal string `mapstructure:"no-global"` AttrOnly bool `mapstructure:"attr-only"` ContextOnly bool `mapstructure:"context-only"` StaticMsg bool `mapstructure:"static-msg"` diff --git a/pkg/golinters/sloglint.go b/pkg/golinters/sloglint.go index acea90d53646..67977453e495 100644 --- a/pkg/golinters/sloglint.go +++ b/pkg/golinters/sloglint.go @@ -14,6 +14,7 @@ func NewSlogLint(settings *config.SlogLintSettings) *goanalysis.Linter { opts = &sloglint.Options{ NoMixedArgs: settings.NoMixedArgs, KVOnly: settings.KVOnly, + NoGlobal: settings.NoGlobal, AttrOnly: settings.AttrOnly, ContextOnly: settings.ContextOnly, StaticMsg: settings.StaticMsg,