Skip to content

Commit 32e5b2b

Browse files
authored
build(deps): github.com/macabu/inamedparam from 0.1.2 to 0.1.3 (#4261)
1 parent 815556a commit 32e5b2b

File tree

8 files changed

+57
-10
lines changed

8 files changed

+57
-10
lines changed

.golangci.reference.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,11 @@ linters-settings:
12361236
- pkg: knative.dev/serving/pkg/apis/(\w+)/(v[\w\d]+)
12371237
alias: $1$2
12381238

1239+
inamedparam:
1240+
# Skips check for interface methods with only a single parameter.
1241+
# Default: false
1242+
skip-single-param: true
1243+
12391244
interfacebloat:
12401245
# The maximum number of methods allowed for an interface.
12411246
# Default: 10

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ require (
6868
github.com/ldez/tagliatelle v0.5.0
6969
github.com/leonklingele/grouper v1.1.1
7070
github.com/lufeee/execinquery v1.2.1
71-
github.com/macabu/inamedparam v0.1.2
71+
github.com/macabu/inamedparam v0.1.3
7272
github.com/maratori/testableexamples v1.0.0
7373
github.com/maratori/testpackage v1.1.1
7474
github.com/matoous/godox v0.0.0-20230222163458-006bad1f9d26
@@ -194,7 +194,7 @@ require (
194194
golang.org/x/mod v0.14.0 // indirect
195195
golang.org/x/sync v0.5.0 // indirect
196196
golang.org/x/sys v0.15.0 // indirect
197-
golang.org/x/text v0.13.0 // indirect
197+
golang.org/x/text v0.14.0 // indirect
198198
google.golang.org/protobuf v1.28.0 // indirect
199199
gopkg.in/ini.v1 v1.67.0 // indirect
200200
gopkg.in/yaml.v2 v2.4.0 // indirect

go.sum

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

pkg/config/linters_settings.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ var defaultLintersSettings = LintersSettings{
7474
MaxDeclLines: 1,
7575
MaxDeclChars: 30,
7676
},
77+
Inamedparam: INamedParamSettings{
78+
SkipSingleParam: false,
79+
},
7780
InterfaceBloat: InterfaceBloatSettings{
7881
Max: 10,
7982
},
@@ -216,6 +219,7 @@ type LintersSettings struct {
216219
Grouper GrouperSettings
217220
Ifshort IfshortSettings
218221
ImportAs ImportAsSettings
222+
Inamedparam INamedParamSettings
219223
InterfaceBloat InterfaceBloatSettings
220224
Ireturn IreturnSettings
221225
Lll LllSettings
@@ -614,6 +618,10 @@ type ImportAsAlias struct {
614618
Alias string
615619
}
616620

621+
type INamedParamSettings struct {
622+
SkipSingleParam bool `mapstructure:"skip-single-param"`
623+
}
624+
617625
type InterfaceBloatSettings struct {
618626
Max int `mapstructure:"max"`
619627
}

pkg/golinters/inamedparam.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,27 @@ import (
44
"github.com/macabu/inamedparam"
55
"golang.org/x/tools/go/analysis"
66

7+
"github.com/golangci/golangci-lint/pkg/config"
78
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
89
)
910

10-
func NewINamedParam() *goanalysis.Linter {
11+
func NewINamedParam(settings *config.INamedParamSettings) *goanalysis.Linter {
1112
a := inamedparam.Analyzer
1213

14+
var cfg map[string]map[string]any
15+
16+
if settings != nil {
17+
cfg = map[string]map[string]any{
18+
a.Name: {
19+
"skip-single-param": settings.SkipSingleParam,
20+
},
21+
}
22+
}
23+
1324
return goanalysis.NewLinter(
1425
a.Name,
1526
a.Doc,
1627
[]*analysis.Analyzer{a},
17-
nil,
28+
cfg,
1829
).WithLoadMode(goanalysis.LoadModeSyntax)
1930
}

pkg/lint/lintersdb/manager.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
105105
grouperCfg *config.GrouperSettings
106106
ifshortCfg *config.IfshortSettings
107107
importAsCfg *config.ImportAsSettings
108+
inamedparamCfg *config.INamedParamSettings
108109
interfaceBloatCfg *config.InterfaceBloatSettings
109110
ireturnCfg *config.IreturnSettings
110111
lllCfg *config.LllSettings
@@ -189,6 +190,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
189190
grouperCfg = &m.cfg.LintersSettings.Grouper
190191
ifshortCfg = &m.cfg.LintersSettings.Ifshort
191192
importAsCfg = &m.cfg.LintersSettings.ImportAs
193+
inamedparamCfg = &m.cfg.LintersSettings.Inamedparam
192194
interfaceBloatCfg = &m.cfg.LintersSettings.InterfaceBloat
193195
ireturnCfg = &m.cfg.LintersSettings.Ireturn
194196
lllCfg = &m.cfg.LintersSettings.Lll
@@ -584,7 +586,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
584586
WithLoadForGoAnalysis().
585587
WithURL("https://github.com/julz/importas"),
586588

587-
linter.NewConfig(golinters.NewINamedParam()).
589+
linter.NewConfig(golinters.NewINamedParam(inamedparamCfg)).
588590
WithSince("v1.55.0").
589591
WithPresets(linter.PresetStyle).
590592
WithURL("https://github.com/macabu/inamedparam"),
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
linters-settings:
2+
inamedparam:
3+
skip-single-param: true
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//golangcitest:args -Einamedparam
2+
//golangcitest:config_path testdata/configs/inamedparam_skip_single_param.yml
3+
package testdata
4+
5+
import "context"
6+
7+
type NamedParam interface {
8+
Void()
9+
10+
SingleParam(string) error
11+
12+
WithName(ctx context.Context, number int, toggle bool) (bool, error)
13+
14+
WithoutName(
15+
context.Context, // want "interface method WithoutName must have named param for type context.Context"
16+
int, // want "interface method WithoutName must have named param for type int"
17+
)
18+
}

0 commit comments

Comments
 (0)