Skip to content

Commit 7ea621b

Browse files
authored
build(deps): bump go-simpler.org/sloglint from 0.5.1 to 0.6.0 (#4645)
1 parent 15c57c1 commit 7ea621b

File tree

9 files changed

+29
-14
lines changed

9 files changed

+29
-14
lines changed

.golangci.next.reference.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,8 +2014,12 @@ linters-settings:
20142014
# Default: ""
20152015
no-global: "all"
20162016
# Enforce using methods that accept a context.
2017-
# Default: false
2018-
context-only: true
2017+
# Values:
2018+
# - "": disabled
2019+
# - "all": report all contextless calls
2020+
# - "scope": report only if a context exists in the scope of the outermost function
2021+
# Default: ""
2022+
context: "all"
20192023
# Enforce using static values for log messages.
20202024
# Default: false
20212025
static-msg: true

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ require (
121121
github.com/ykadowak/zerologlint v0.1.5
122122
gitlab.com/bosi/decorder v0.4.1
123123
go-simpler.org/musttag v0.12.1
124-
go-simpler.org/sloglint v0.5.1
124+
go-simpler.org/sloglint v0.6.0
125125
go.uber.org/automaxprocs v1.5.3
126126
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc
127127
golang.org/x/tools v0.20.0

go.sum

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jsonschema/golangci.next.jsonschema.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2289,10 +2289,10 @@
22892289
"type": "boolean",
22902290
"default": true
22912291
},
2292-
"context-only": {
2292+
"context": {
22932293
"description": "Enforce using methods that accept a context.",
2294-
"type": "boolean",
2295-
"default": false
2294+
"enum": ["", "all", "scope"],
2295+
"default": ""
22962296
},
22972297
"static-msg": {
22982298
"description": "Enforce using static values for log messages.",

pkg/config/linters_settings.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ var defaultLintersSettings = LintersSettings{
144144
NoMixedArgs: true,
145145
KVOnly: false,
146146
AttrOnly: false,
147+
NoGlobal: "",
148+
Context: "",
147149
ContextOnly: false,
148150
StaticMsg: false,
149151
NoRawKeys: false,
@@ -810,9 +812,10 @@ type RowsErrCheckSettings struct {
810812
type SlogLintSettings struct {
811813
NoMixedArgs bool `mapstructure:"no-mixed-args"`
812814
KVOnly bool `mapstructure:"kv-only"`
813-
NoGlobal string `mapstructure:"no-global"`
814815
AttrOnly bool `mapstructure:"attr-only"`
815-
ContextOnly bool `mapstructure:"context-only"`
816+
NoGlobal string `mapstructure:"no-global"`
817+
Context string `mapstructure:"context"`
818+
ContextOnly bool `mapstructure:"context-only"` // Deprecated: use Context instead.
816819
StaticMsg bool `mapstructure:"static-msg"`
817820
NoRawKeys bool `mapstructure:"no-raw-keys"`
818821
KeyNamingCase string `mapstructure:"key-naming-case"`

pkg/config/loader.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,14 @@ func (l *Loader) handleLinterOptionDeprecations() {
408408
if l.cfg.LintersSettings.Stylecheck.GoVersion != "" {
409409
l.log.Warnf("The configuration option `linters.stylecheck.go` is deprecated, please use global `run.go`.")
410410
}
411+
412+
// Deprecated since v1.58.0
413+
if l.cfg.LintersSettings.SlogLint.ContextOnly {
414+
l.log.Warnf("The configuration option `linters.sloglint.context-only` is deprecated, please use `linters.sloglint.context`")
415+
if l.cfg.LintersSettings.SlogLint.Context == "" {
416+
l.cfg.LintersSettings.SlogLint.Context = "all"
417+
}
418+
}
411419
}
412420

413421
func (l *Loader) handleEnableOnlyOption() error {

pkg/golinters/sloglint/sloglint.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ func New(settings *config.SlogLintSettings) *goanalysis.Linter {
1414
opts = &sloglint.Options{
1515
NoMixedArgs: settings.NoMixedArgs,
1616
KVOnly: settings.KVOnly,
17-
NoGlobal: settings.NoGlobal,
1817
AttrOnly: settings.AttrOnly,
19-
ContextOnly: settings.ContextOnly,
18+
NoGlobal: settings.NoGlobal,
19+
ContextOnly: settings.Context,
2020
StaticMsg: settings.StaticMsg,
2121
NoRawKeys: settings.NoRawKeys,
2222
KeyNamingCase: settings.KeyNamingCase,

pkg/golinters/sloglint/testdata/sloglint_context_only.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ import (
1212
func test() {
1313
slog.InfoContext(context.Background(), "msg")
1414

15-
slog.Info("msg") // want `methods without a context should not be used`
15+
slog.Info("msg") // want `InfoContext should be used instead`
1616
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
linters-settings:
22
sloglint:
3-
context-only: true
3+
context: "all"

0 commit comments

Comments
 (0)