build(deps): bump go-simpler.org/sloglint from 0.1.2 to 0.2.0 (#4166)
This commit is contained in:
parent
2b7c777bb2
commit
f17fef34b2
@ -1824,9 +1824,16 @@ linters-settings:
|
|||||||
# Enforce using attributes only (incompatible with kv-only).
|
# Enforce using attributes only (incompatible with kv-only).
|
||||||
# Default: false
|
# Default: false
|
||||||
attr-only: true
|
attr-only: true
|
||||||
|
# Enforce using methods that accept a context.
|
||||||
|
# Default: false
|
||||||
|
context-only: true
|
||||||
# Enforce using constants instead of raw keys.
|
# Enforce using constants instead of raw keys.
|
||||||
# Default: false
|
# Default: false
|
||||||
no-raw-keys: true
|
no-raw-keys: true
|
||||||
|
# Enforce a single key naming convention.
|
||||||
|
# Values: snake, kebab, camel, pascal
|
||||||
|
# Default: ""
|
||||||
|
key-naming-case: snake
|
||||||
# Enforce putting arguments on separate lines.
|
# Enforce putting arguments on separate lines.
|
||||||
# Default: false
|
# Default: false
|
||||||
args-on-sep-lines: true
|
args-on-sep-lines: true
|
||||||
|
2
go.mod
2
go.mod
@ -120,7 +120,7 @@ require (
|
|||||||
github.com/yeya24/promlinter v0.2.0
|
github.com/yeya24/promlinter v0.2.0
|
||||||
github.com/ykadowak/zerologlint v0.1.3
|
github.com/ykadowak/zerologlint v0.1.3
|
||||||
gitlab.com/bosi/decorder v0.4.1
|
gitlab.com/bosi/decorder v0.4.1
|
||||||
go-simpler.org/sloglint v0.1.2
|
go-simpler.org/sloglint v0.2.0
|
||||||
go.tmz.dev/musttag v0.7.2
|
go.tmz.dev/musttag v0.7.2
|
||||||
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea
|
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea
|
||||||
golang.org/x/tools v0.14.0
|
golang.org/x/tools v0.14.0
|
||||||
|
2
go.sum
generated
2
go.sum
generated
@ -592,6 +592,8 @@ gitlab.com/bosi/decorder v0.4.1/go.mod h1:jecSqWUew6Yle1pCr2eLWTensJMmsxHsBwt+PV
|
|||||||
go-simpler.org/assert v0.6.0 h1:QxSrXa4oRuo/1eHMXSBFHKvJIpWABayzKldqZyugG7E=
|
go-simpler.org/assert v0.6.0 h1:QxSrXa4oRuo/1eHMXSBFHKvJIpWABayzKldqZyugG7E=
|
||||||
go-simpler.org/sloglint v0.1.2 h1:IjdhF8NPxyn0Ckn2+fuIof7ntSnVUAqBFcQRrnG9AiM=
|
go-simpler.org/sloglint v0.1.2 h1:IjdhF8NPxyn0Ckn2+fuIof7ntSnVUAqBFcQRrnG9AiM=
|
||||||
go-simpler.org/sloglint v0.1.2/go.mod h1:2LL+QImPfTslD5muNPydAEYmpXIj6o/WYcqnJjLi4o4=
|
go-simpler.org/sloglint v0.1.2/go.mod h1:2LL+QImPfTslD5muNPydAEYmpXIj6o/WYcqnJjLi4o4=
|
||||||
|
go-simpler.org/sloglint v0.2.0 h1:XpOhA+7BCQJnl7KlDLmnFUFTSrl989ZmaVPSWWCWEtc=
|
||||||
|
go-simpler.org/sloglint v0.2.0/go.mod h1:/RQr0TeTf89IyRjLJ9ogUbIp1Zs5zJJAj02pwQoDQdg=
|
||||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
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.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||||
|
@ -119,7 +119,9 @@ var defaultLintersSettings = LintersSettings{
|
|||||||
SlogLint: SlogLintSettings{
|
SlogLint: SlogLintSettings{
|
||||||
KVOnly: false,
|
KVOnly: false,
|
||||||
AttrOnly: false,
|
AttrOnly: false,
|
||||||
|
ContextOnly: false,
|
||||||
NoRawKeys: false,
|
NoRawKeys: false,
|
||||||
|
KeyNamingCase: "",
|
||||||
ArgsOnSepLines: false,
|
ArgsOnSepLines: false,
|
||||||
},
|
},
|
||||||
TagAlign: TagAlignSettings{
|
TagAlign: TagAlignSettings{
|
||||||
@ -734,10 +736,12 @@ type RowsErrCheckSettings struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SlogLintSettings struct {
|
type SlogLintSettings struct {
|
||||||
KVOnly bool `mapstructure:"kv-only"`
|
KVOnly bool `mapstructure:"kv-only"`
|
||||||
AttrOnly bool `mapstructure:"attr-only"`
|
AttrOnly bool `mapstructure:"attr-only"`
|
||||||
NoRawKeys bool `mapstructure:"no-raw-keys"`
|
ContextOnly bool `mapstructure:"context-only"`
|
||||||
ArgsOnSepLines bool `mapstructure:"args-on-sep-lines"`
|
NoRawKeys bool `mapstructure:"no-raw-keys"`
|
||||||
|
KeyNamingCase string `mapstructure:"key-naming-case"`
|
||||||
|
ArgsOnSepLines bool `mapstructure:"args-on-sep-lines"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type StaticCheckSettings struct {
|
type StaticCheckSettings struct {
|
||||||
|
@ -14,7 +14,9 @@ func NewSlogLint(settings *config.SlogLintSettings) *goanalysis.Linter {
|
|||||||
opts = &sloglint.Options{
|
opts = &sloglint.Options{
|
||||||
KVOnly: settings.KVOnly,
|
KVOnly: settings.KVOnly,
|
||||||
AttrOnly: settings.AttrOnly,
|
AttrOnly: settings.AttrOnly,
|
||||||
|
ContextOnly: settings.ContextOnly,
|
||||||
NoRawKeys: settings.NoRawKeys,
|
NoRawKeys: settings.NoRawKeys,
|
||||||
|
KeyNamingCase: settings.KeyNamingCase,
|
||||||
ArgsOnSepLines: settings.ArgsOnSepLines,
|
ArgsOnSepLines: settings.ArgsOnSepLines,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
test/testdata/configs/sloglint_context_only.yml
vendored
Normal file
3
test/testdata/configs/sloglint_context_only.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
sloglint:
|
||||||
|
context-only: true
|
3
test/testdata/configs/sloglint_key_naming_case.yml
vendored
Normal file
3
test/testdata/configs/sloglint_key_naming_case.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
sloglint:
|
||||||
|
key-naming-case: snake
|
16
test/testdata/sloglint_context_only.go
vendored
Normal file
16
test/testdata/sloglint_context_only.go
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
//go:build go1.21
|
||||||
|
|
||||||
|
//golangcitest:args -Esloglint
|
||||||
|
//golangcitest:config_path testdata/configs/sloglint_context_only.yml
|
||||||
|
package testdata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"log/slog"
|
||||||
|
)
|
||||||
|
|
||||||
|
func test() {
|
||||||
|
slog.InfoContext(context.Background(), "msg")
|
||||||
|
|
||||||
|
slog.Info("msg") // want `methods without a context should not be used`
|
||||||
|
}
|
24
test/testdata/sloglint_key_naming_case.go
vendored
Normal file
24
test/testdata/sloglint_key_naming_case.go
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
//go:build go1.21
|
||||||
|
|
||||||
|
//golangcitest:args -Esloglint
|
||||||
|
//golangcitest:config_path testdata/configs/sloglint_key_naming_case.yml
|
||||||
|
package testdata
|
||||||
|
|
||||||
|
import "log/slog"
|
||||||
|
|
||||||
|
const (
|
||||||
|
snakeKey = "foo_bar"
|
||||||
|
kebabKey = "foo-bar"
|
||||||
|
)
|
||||||
|
|
||||||
|
func test() {
|
||||||
|
slog.Info("msg", "foo_bar", 1)
|
||||||
|
slog.Info("msg", snakeKey, 1)
|
||||||
|
slog.Info("msg", slog.Int("foo_bar", 1))
|
||||||
|
slog.Info("msg", slog.Int(snakeKey, 1))
|
||||||
|
|
||||||
|
slog.Info("msg", "foo-bar", 1) // want `keys should be written in snake_case`
|
||||||
|
slog.Info("msg", kebabKey, 1) // want `keys should be written in snake_case`
|
||||||
|
slog.Info("msg", slog.Int("foo-bar", 1)) // want `keys should be written in snake_case`
|
||||||
|
slog.Info("msg", slog.Int(kebabKey, 1)) // want `keys should be written in snake_case`
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user