File tree 6 files changed +81
-0
lines changed
6 files changed +81
-0
lines changed Original file line number Diff line number Diff line change @@ -1072,6 +1072,9 @@ linters-settings:
1072
1072
- pkg : knative.dev/serving/pkg/apis/(\w+)/(v[\w\d]+)
1073
1073
alias : $1$2
1074
1074
1075
+ interfacebloat :
1076
+ interface-len : 10
1077
+
1075
1078
ireturn :
1076
1079
# ireturn allows using `allow` and `reject` settings at the same time.
1077
1080
# Both settings are lists of the keywords and regular expressions matched to interface or package names.
@@ -1921,6 +1924,7 @@ linters:
1921
1924
- ifshort
1922
1925
- importas
1923
1926
- ineffassign
1927
+ - interfacebloat
1924
1928
- interfacer
1925
1929
- ireturn
1926
1930
- lll
@@ -2023,6 +2027,7 @@ linters:
2023
2027
- ifshort
2024
2028
- importas
2025
2029
- ineffassign
2030
+ - interfacebloat
2026
2031
- interfacer
2027
2032
- ireturn
2028
2033
- lll
Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ require (
74
74
github.com/ryancurrah/gomodguard v1.2.4
75
75
github.com/ryanrolds/sqlclosecheck v0.3.0
76
76
github.com/sanposhiho/wastedassign/v2 v2.0.6
77
+ github.com/sashamelentyev/interfacebloat v1.0.0
77
78
github.com/sashamelentyev/usestdlibvars v1.10.0
78
79
github.com/securego/gosec/v2 v2.12.0
79
80
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c
Original file line number Diff line number Diff line change
1
+ package golinters
2
+
3
+ import (
4
+ "github.com/sashamelentyev/interfacebloat/pkg/analyzer"
5
+ "golang.org/x/tools/go/analysis"
6
+
7
+ "github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
8
+ )
9
+
10
+ func NewInterfaceBloat () * goanalysis.Linter {
11
+ a := analyzer .New ()
12
+
13
+ return goanalysis .NewLinter (
14
+ a .Name ,
15
+ a .Doc ,
16
+ []* analysis.Analyzer {a },
17
+ nil ,
18
+ )
19
+ }
Original file line number Diff line number Diff line change @@ -557,6 +557,12 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
557
557
WithPresets (linter .PresetUnused ).
558
558
WithURL ("https://github.com/gordonklaus/ineffassign" ),
559
559
560
+ linter .NewConfig (golinters .NewInterfaceBloat ()).
561
+ WithSince ("v1.48.0" ).
562
+ WithLoadForGoAnalysis ().
563
+ WithPresets (linter .PresetStyle ).
564
+ WithURL ("https://github.com/sashamelentyev/interfacebloat" ),
565
+
560
566
linter .NewConfig (golinters .NewInterfacer ()).
561
567
WithSince ("v1.0.0" ).
562
568
WithLoadForGoAnalysis ().
Original file line number Diff line number Diff line change
1
+ //golangcitest:args -Einterfacebloat
2
+ package testdata
3
+
4
+ type _ interface { // want "length of interface greater than 10"
5
+ a ()
6
+ b ()
7
+ c ()
8
+ d ()
9
+ f ()
10
+ g ()
11
+ h ()
12
+ i ()
13
+ j ()
14
+ k ()
15
+ l ()
16
+ }
17
+
18
+ func _ () {
19
+ var _ interface { // want "length of interface greater than 10"
20
+ a ()
21
+ b ()
22
+ c ()
23
+ d ()
24
+ f ()
25
+ g ()
26
+ h ()
27
+ i ()
28
+ j ()
29
+ k ()
30
+ l ()
31
+ }
32
+ }
33
+
34
+ func __ () interface { // want "length of interface greater than 10"
35
+ a ()
36
+ b ()
37
+ c ()
38
+ d ()
39
+ f ()
40
+ g ()
41
+ h ()
42
+ i ()
43
+ j ()
44
+ k ()
45
+ l ()
46
+ } {
47
+ return nil
48
+ }
You can’t perform that action at this time.
0 commit comments