build(deps): bump go-simpler.org/sloglint from 0.6.0 to 0.7.0 (#4718)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
This commit is contained in:
parent
d94cbbf504
commit
be1bb6dbf7
@ -1997,12 +1997,15 @@ linters-settings:
|
||||
|
||||
sloglint:
|
||||
# Enforce not mixing key-value pairs and attributes.
|
||||
# https://github.com/go-simpler/sloglint?tab=readme-ov-file#no-mixed-arguments
|
||||
# Default: true
|
||||
no-mixed-args: false
|
||||
# Enforce using key-value pairs only (overrides no-mixed-args, incompatible with attr-only).
|
||||
# https://github.com/go-simpler/sloglint?tab=readme-ov-file#key-value-pairs-only
|
||||
# Default: false
|
||||
kv-only: true
|
||||
# Enforce using attributes only (overrides no-mixed-args, incompatible with kv-only).
|
||||
# https://github.com/go-simpler/sloglint?tab=readme-ov-file#attributes-only
|
||||
# Default: false
|
||||
attr-only: true
|
||||
# Enforce not using global loggers.
|
||||
@ -2010,6 +2013,7 @@ linters-settings:
|
||||
# - "": disabled
|
||||
# - "all": report all global loggers
|
||||
# - "default": report only the default slog logger
|
||||
# https://github.com/go-simpler/sloglint?tab=readme-ov-file#no-global
|
||||
# Default: ""
|
||||
no-global: "all"
|
||||
# Enforce using methods that accept a context.
|
||||
@ -2017,19 +2021,32 @@ linters-settings:
|
||||
# - "": disabled
|
||||
# - "all": report all contextless calls
|
||||
# - "scope": report only if a context exists in the scope of the outermost function
|
||||
# https://github.com/go-simpler/sloglint?tab=readme-ov-file#context-only
|
||||
# Default: ""
|
||||
context: "all"
|
||||
# Enforce using static values for log messages.
|
||||
# https://github.com/go-simpler/sloglint?tab=readme-ov-file#static-messages
|
||||
# Default: false
|
||||
static-msg: true
|
||||
# Enforce using constants instead of raw keys.
|
||||
# https://github.com/go-simpler/sloglint?tab=readme-ov-file#no-raw-keys
|
||||
# Default: false
|
||||
no-raw-keys: true
|
||||
# Enforce a single key naming convention.
|
||||
# Values: snake, kebab, camel, pascal
|
||||
# https://github.com/go-simpler/sloglint?tab=readme-ov-file#key-naming-convention
|
||||
# Default: ""
|
||||
key-naming-case: snake
|
||||
# Enforce not using specific keys.
|
||||
# Default: []
|
||||
forbidden-keys:
|
||||
- time
|
||||
- level
|
||||
- msg
|
||||
- source
|
||||
- foo
|
||||
# Enforce putting arguments on separate lines.
|
||||
# https://github.com/go-simpler/sloglint?tab=readme-ov-file#forbidden-keys
|
||||
# Default: false
|
||||
args-on-sep-lines: true
|
||||
|
||||
|
2
go.mod
2
go.mod
@ -122,7 +122,7 @@ require (
|
||||
github.com/ykadowak/zerologlint v0.1.5
|
||||
gitlab.com/bosi/decorder v0.4.2
|
||||
go-simpler.org/musttag v0.12.2
|
||||
go-simpler.org/sloglint v0.6.0
|
||||
go-simpler.org/sloglint v0.7.0
|
||||
go.uber.org/automaxprocs v1.5.3
|
||||
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc
|
||||
golang.org/x/tools v0.21.0
|
||||
|
4
go.sum
generated
4
go.sum
generated
@ -594,8 +594,8 @@ go-simpler.org/assert v0.9.0 h1:PfpmcSvL7yAnWyChSjOz6Sp6m9j5lyK8Ok9pEL31YkQ=
|
||||
go-simpler.org/assert v0.9.0/go.mod h1:74Eqh5eI6vCK6Y5l3PI8ZYFXG4Sa+tkr70OIPJAUr28=
|
||||
go-simpler.org/musttag v0.12.2 h1:J7lRc2ysXOq7eM8rwaTYnNrHd5JwjppzB6mScysB2Cs=
|
||||
go-simpler.org/musttag v0.12.2/go.mod h1:uN1DVIasMTQKk6XSik7yrJoEysGtR2GRqvWnI9S7TYM=
|
||||
go-simpler.org/sloglint v0.6.0 h1:0YcqSVG7LI9EVBfRPhgPec79BH6X6mwjFuUR5Mr7j1M=
|
||||
go-simpler.org/sloglint v0.6.0/go.mod h1:+kJJtebtPePWyG5boFwY46COydAggADDOHM22zOvzBk=
|
||||
go-simpler.org/sloglint v0.7.0 h1:rMZRxD9MbaGoRFobIOicMxZzum7AXNFDlez6xxJs5V4=
|
||||
go-simpler.org/sloglint v0.7.0/go.mod h1:g9SXiSWY0JJh4LS39/Q0GxzP/QX2cVcbTOYhDpXrJEs=
|
||||
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=
|
||||
|
@ -2468,6 +2468,13 @@
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"forbidden-keys": {
|
||||
"description": "Enforce not using specific keys.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"args-on-sep-lines": {
|
||||
"description": "Enforce putting arguments on separate lines.",
|
||||
"type": "boolean",
|
||||
|
@ -146,10 +146,10 @@ var defaultLintersSettings = LintersSettings{
|
||||
AttrOnly: false,
|
||||
NoGlobal: "",
|
||||
Context: "",
|
||||
ContextOnly: false,
|
||||
StaticMsg: false,
|
||||
NoRawKeys: false,
|
||||
KeyNamingCase: "",
|
||||
ForbiddenKeys: nil,
|
||||
ArgsOnSepLines: false,
|
||||
},
|
||||
TagAlign: TagAlignSettings{
|
||||
@ -819,16 +819,19 @@ type RowsErrCheckSettings struct {
|
||||
}
|
||||
|
||||
type SlogLintSettings struct {
|
||||
NoMixedArgs bool `mapstructure:"no-mixed-args"`
|
||||
KVOnly bool `mapstructure:"kv-only"`
|
||||
AttrOnly bool `mapstructure:"attr-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"`
|
||||
ArgsOnSepLines bool `mapstructure:"args-on-sep-lines"`
|
||||
NoMixedArgs bool `mapstructure:"no-mixed-args"`
|
||||
KVOnly bool `mapstructure:"kv-only"`
|
||||
AttrOnly bool `mapstructure:"attr-only"`
|
||||
NoGlobal string `mapstructure:"no-global"`
|
||||
Context string `mapstructure:"context"`
|
||||
StaticMsg bool `mapstructure:"static-msg"`
|
||||
NoRawKeys bool `mapstructure:"no-raw-keys"`
|
||||
KeyNamingCase string `mapstructure:"key-naming-case"`
|
||||
ForbiddenKeys []string `mapstructure:"forbidden-keys"`
|
||||
ArgsOnSepLines bool `mapstructure:"args-on-sep-lines"`
|
||||
|
||||
// Deprecated: use Context instead.
|
||||
ContextOnly bool `mapstructure:"context-only"`
|
||||
}
|
||||
|
||||
type SpancheckSettings struct {
|
||||
|
@ -20,6 +20,7 @@ func New(settings *config.SlogLintSettings) *goanalysis.Linter {
|
||||
StaticMsg: settings.StaticMsg,
|
||||
NoRawKeys: settings.NoRawKeys,
|
||||
KeyNamingCase: settings.KeyNamingCase,
|
||||
ForbiddenKeys: settings.ForbiddenKeys,
|
||||
ArgsOnSepLines: settings.ArgsOnSepLines,
|
||||
}
|
||||
}
|
||||
|
28
pkg/golinters/sloglint/testdata/sloglint_forbidden_keys.go
vendored
Normal file
28
pkg/golinters/sloglint/testdata/sloglint_forbidden_keys.go
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
//golangcitest:args -Esloglint
|
||||
//golangcitest:config_path testdata/sloglint_forbidden_keys.yml
|
||||
package testdata
|
||||
|
||||
import "log/slog"
|
||||
|
||||
const (
|
||||
snakeKey = "foo_bar"
|
||||
)
|
||||
|
||||
func tests() {
|
||||
slog.Info("msg")
|
||||
slog.Info("msg", "foo-bar", 1)
|
||||
slog.Info("msg", "foo_bar", 1) // want `"foo_bar" key is forbidden and should not be used`
|
||||
slog.Info("msg", snakeKey, 1) // want `"foo_bar" key is forbidden and should not be used`
|
||||
slog.Info("msg", slog.Int("foo_bar", 1)) // want `"foo_bar" key is forbidden and should not be used`
|
||||
slog.Info("msg", slog.Int(snakeKey, 1)) // want `"foo_bar" key is forbidden and should not be used`
|
||||
slog.Info("msg", slog.Attr{})
|
||||
slog.Info("msg", slog.Attr{"foo_bar", slog.IntValue(1)}) // want `"foo_bar" key is forbidden and should not be used`
|
||||
slog.Info("msg", slog.Attr{snakeKey, slog.IntValue(1)}) // want `"foo_bar" key is forbidden and should not be used`
|
||||
slog.Info("msg", slog.Attr{Key: "foo_bar"}) // want `"foo_bar" key is forbidden and should not be used`
|
||||
slog.Info("msg", slog.Attr{Key: snakeKey}) // want `"foo_bar" key is forbidden and should not be used`
|
||||
slog.Info("msg", slog.Attr{Key: "foo_bar", Value: slog.IntValue(1)}) // want `"foo_bar" key is forbidden and should not be used`
|
||||
slog.Info("msg", slog.Attr{Key: snakeKey, Value: slog.IntValue(1)}) // want `"foo_bar" key is forbidden and should not be used`
|
||||
slog.Info("msg", slog.Attr{Value: slog.IntValue(1), Key: "foo_bar"}) // want `"foo_bar" key is forbidden and should not be used`
|
||||
slog.Info("msg", slog.Attr{Value: slog.IntValue(1), Key: snakeKey}) // want `"foo_bar" key is forbidden and should not be used`
|
||||
slog.Info("msg", slog.Attr{Value: slog.IntValue(1), Key: `foo_bar`}) // want `"foo_bar" key is forbidden and should not be used`
|
||||
}
|
4
pkg/golinters/sloglint/testdata/sloglint_forbidden_keys.yml
vendored
Normal file
4
pkg/golinters/sloglint/testdata/sloglint_forbidden_keys.yml
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
linters-settings:
|
||||
sloglint:
|
||||
forbidden-keys:
|
||||
- foo_bar
|
Loading…
x
Reference in New Issue
Block a user