build(deps): bump go-simpler.org/sloglint from 0.5.1 to 0.6.0 (#4645)

This commit is contained in:
Tom 2024-04-20 22:48:01 +05:00 committed by GitHub
parent 15c57c176e
commit 7ea621b83a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 29 additions and 14 deletions

View File

@ -2014,8 +2014,12 @@ linters-settings:
# Default: ""
no-global: "all"
# Enforce using methods that accept a context.
# Default: false
context-only: true
# Values:
# - "": disabled
# - "all": report all contextless calls
# - "scope": report only if a context exists in the scope of the outermost function
# Default: ""
context: "all"
# Enforce using static values for log messages.
# Default: false
static-msg: true

2
go.mod
View File

@ -121,7 +121,7 @@ require (
github.com/ykadowak/zerologlint v0.1.5
gitlab.com/bosi/decorder v0.4.1
go-simpler.org/musttag v0.12.1
go-simpler.org/sloglint v0.5.1
go-simpler.org/sloglint v0.6.0
go.uber.org/automaxprocs v1.5.3
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc
golang.org/x/tools v0.20.0

4
go.sum generated
View File

@ -592,8 +592,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.12.1 h1:yaMcjl/uyVnd1z6GqIhBiFH/PoqNN9f2IgtU7bp7W/0=
go-simpler.org/musttag v0.12.1/go.mod h1:46HKu04A3Am9Lne5kKP0ssgwY3AeIlqsDzz3UxKROpY=
go-simpler.org/sloglint v0.5.1 h1:v4b9ave8MidsW28AkkRnF6Syg109zDgsYLiTlB5Ldew=
go-simpler.org/sloglint v0.5.1/go.mod h1:+kJJtebtPePWyG5boFwY46COydAggADDOHM22zOvzBk=
go-simpler.org/sloglint v0.6.0 h1:0YcqSVG7LI9EVBfRPhgPec79BH6X6mwjFuUR5Mr7j1M=
go-simpler.org/sloglint v0.6.0/go.mod h1:+kJJtebtPePWyG5boFwY46COydAggADDOHM22zOvzBk=
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=

View File

@ -2289,10 +2289,10 @@
"type": "boolean",
"default": true
},
"context-only": {
"context": {
"description": "Enforce using methods that accept a context.",
"type": "boolean",
"default": false
"enum": ["", "all", "scope"],
"default": ""
},
"static-msg": {
"description": "Enforce using static values for log messages.",

View File

@ -144,6 +144,8 @@ var defaultLintersSettings = LintersSettings{
NoMixedArgs: true,
KVOnly: false,
AttrOnly: false,
NoGlobal: "",
Context: "",
ContextOnly: false,
StaticMsg: false,
NoRawKeys: false,
@ -810,9 +812,10 @@ 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"`
NoGlobal string `mapstructure:"no-global"`
Context string `mapstructure:"context"`
ContextOnly bool `mapstructure:"context-only"` // Deprecated: use Context instead.
StaticMsg bool `mapstructure:"static-msg"`
NoRawKeys bool `mapstructure:"no-raw-keys"`
KeyNamingCase string `mapstructure:"key-naming-case"`

View File

@ -408,6 +408,14 @@ func (l *Loader) handleLinterOptionDeprecations() {
if l.cfg.LintersSettings.Stylecheck.GoVersion != "" {
l.log.Warnf("The configuration option `linters.stylecheck.go` is deprecated, please use global `run.go`.")
}
// Deprecated since v1.58.0
if l.cfg.LintersSettings.SlogLint.ContextOnly {
l.log.Warnf("The configuration option `linters.sloglint.context-only` is deprecated, please use `linters.sloglint.context`")
if l.cfg.LintersSettings.SlogLint.Context == "" {
l.cfg.LintersSettings.SlogLint.Context = "all"
}
}
}
func (l *Loader) handleEnableOnlyOption() error {

View File

@ -14,9 +14,9 @@ func New(settings *config.SlogLintSettings) *goanalysis.Linter {
opts = &sloglint.Options{
NoMixedArgs: settings.NoMixedArgs,
KVOnly: settings.KVOnly,
NoGlobal: settings.NoGlobal,
AttrOnly: settings.AttrOnly,
ContextOnly: settings.ContextOnly,
NoGlobal: settings.NoGlobal,
ContextOnly: settings.Context,
StaticMsg: settings.StaticMsg,
NoRawKeys: settings.NoRawKeys,
KeyNamingCase: settings.KeyNamingCase,

View File

@ -12,5 +12,5 @@ import (
func test() {
slog.InfoContext(context.Background(), "msg")
slog.Info("msg") // want `methods without a context should not be used`
slog.Info("msg") // want `InfoContext should be used instead`
}

View File

@ -1,3 +1,3 @@
linters-settings:
sloglint:
context-only: true
context: "all"