Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita1dbfe1

Browse files
authored
Merge branch 'master' into go-factory-lint
2 parentsdf588bc +32e5b2b commita1dbfe1

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
@@ -1245,6 +1245,11 @@ linters-settings:
12451245
-pkg:knative.dev/serving/pkg/apis/(\w+)/(v[\w\d]+)
12461246
alias:$1$2
12471247

1248+
inamedparam:
1249+
# Skips check for interface methods with only a single parameter.
1250+
# Default: false
1251+
skip-single-param:true
1252+
12481253
interfacebloat:
12491254
# The maximum number of methods allowed for an interface.
12501255
# 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/tagliatellev0.5.0
6969
github.com/leonklingele/grouperv1.1.1
7070
github.com/lufeee/execinqueryv1.2.1
71-
github.com/macabu/inamedparamv0.1.2
71+
github.com/macabu/inamedparamv0.1.3
7272
github.com/maranqz/gofactoryv1.0.0-rc1
7373
github.com/maratori/testableexamplesv1.0.0
7474
github.com/maratori/testpackagev1.1.1
@@ -195,7 +195,7 @@ require (
195195
golang.org/x/modv0.14.0// indirect
196196
golang.org/x/syncv0.5.0// indirect
197197
golang.org/x/sysv0.15.0// indirect
198-
golang.org/x/textv0.13.0// indirect
198+
golang.org/x/textv0.14.0// indirect
199199
google.golang.org/protobufv1.28.0// indirect
200200
gopkg.in/ini.v1v1.67.0// indirect
201201
gopkg.in/yaml.v2v2.4.0// indirect

‎go.sum‎

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing 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
},
@@ -217,6 +220,7 @@ type LintersSettings struct {
217220
GrouperGrouperSettings
218221
IfshortIfshortSettings
219222
ImportAsImportAsSettings
223+
InamedparamINamedParamSettings
220224
InterfaceBloatInterfaceBloatSettings
221225
IreturnIreturnSettings
222226
LllLllSettings
@@ -620,6 +624,10 @@ type ImportAsAlias struct {
620624
Aliasstring
621625
}
622626

627+
typeINamedParamSettingsstruct {
628+
SkipSingleParambool`mapstructure:"skip-single-param"`
629+
}
630+
623631
typeInterfaceBloatSettingsstruct {
624632
Maxint`mapstructure:"max"`
625633
}

‎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-
funcNewINamedParam()*goanalysis.Linter {
11+
funcNewINamedParam(settings*config.INamedParamSettings)*goanalysis.Linter {
1112
a:=inamedparam.Analyzer
1213

14+
varcfgmap[string]map[string]any
15+
16+
ifsettings!=nil {
17+
cfg=map[string]map[string]any{
18+
a.Name: {
19+
"skip-single-param":settings.SkipSingleParam,
20+
},
21+
}
22+
}
23+
1324
returngoanalysis.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
@@ -106,6 +106,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
106106
grouperCfg*config.GrouperSettings
107107
ifshortCfg*config.IfshortSettings
108108
importAsCfg*config.ImportAsSettings
109+
inamedparamCfg*config.INamedParamSettings
109110
interfaceBloatCfg*config.InterfaceBloatSettings
110111
ireturnCfg*config.IreturnSettings
111112
lllCfg*config.LllSettings
@@ -191,6 +192,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
191192
grouperCfg=&m.cfg.LintersSettings.Grouper
192193
ifshortCfg=&m.cfg.LintersSettings.Ifshort
193194
importAsCfg=&m.cfg.LintersSettings.ImportAs
195+
inamedparamCfg=&m.cfg.LintersSettings.Inamedparam
194196
interfaceBloatCfg=&m.cfg.LintersSettings.InterfaceBloat
195197
ireturnCfg=&m.cfg.LintersSettings.Ireturn
196198
lllCfg=&m.cfg.LintersSettings.Lll
@@ -592,7 +594,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
592594
WithLoadForGoAnalysis().
593595
WithURL("https://github.com/julz/importas"),
594596

595-
linter.NewConfig(golinters.NewINamedParam()).
597+
linter.NewConfig(golinters.NewINamedParam(inamedparamCfg)).
596598
WithSince("v1.55.0").
597599
WithPresets(linter.PresetStyle).
598600
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+
typeNamedParaminterface {
8+
Void()
9+
10+
SingleParam(string)error
11+
12+
WithName(ctx context.Context,numberint,togglebool) (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)

[8]ページ先頭

©2009-2025 Movatter.jp