Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .golangci.next.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions jsonschema/golangci.next.jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
7 changes: 5 additions & 2 deletions pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ var defaultLintersSettings = LintersSettings{
NoMixedArgs: true,
KVOnly: false,
AttrOnly: false,
NoGlobal: "",
Context: "",
ContextOnly: false,
StaticMsg: false,
NoRawKeys: false,
Expand Down Expand Up @@ -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"`
Expand Down
8 changes: 8 additions & 0 deletions pkg/config/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/golinters/sloglint/sloglint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/golinters/sloglint/testdata/sloglint_context_only.go
Original file line number Diff line number Diff line change
Expand Up @@ -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`
}
2 changes: 1 addition & 1 deletion pkg/golinters/sloglint/testdata/sloglint_context_only.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
linters-settings:
sloglint:
context-only: true
context: "all"
Loading