File tree 2 files changed +15
-5
lines changed 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ func run(pass *analysis.Pass) (interface{}, error) {
26
26
inspector .Preorder (nodeFilter , func (node ast.Node ) {
27
27
funcDecl := node .(* ast.FuncDecl )
28
28
29
+ if res := funcDecl .Type .Results ; res != nil && len (res .List ) != 0 {
30
+ return
31
+ }
32
+
29
33
params := funcDecl .Type .Params .List
30
34
if len (params ) < 2 { // [0] must be format (string), [1] must be args (...interface{})
31
35
return
@@ -40,6 +44,10 @@ func run(pass *analysis.Pass) (interface{}, error) {
40
44
return
41
45
}
42
46
47
+ if formatParamNames := params [len (params )- 2 ].Names ; len (formatParamNames ) == 0 || formatParamNames [len (formatParamNames )- 1 ].Name != "format" {
48
+ return
49
+ }
50
+
43
51
argsParamType , ok := params [len (params )- 1 ].Type .(* ast.Ellipsis )
44
52
if ! ok { // args are not ellipsis (...args)
45
53
return
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ func printfLikeButWithStrings(format string, args ...string) {}
8
8
9
9
func printfLikeButWithBadFormat (format int , args ... interface {}) {}
10
10
11
- func secondArgIsNotEllipsis (arg1 string , arg2 int ) {}
11
+ func secondArgIsNotEllipsis (format string , arg int ) {}
12
12
13
13
func printfLikeButWithExtraInterfaceMethods (format string , args ... interface {
14
14
String () string
@@ -17,12 +17,14 @@ func printfLikeButWithExtraInterfaceMethods(format string, args ...interface {
17
17
18
18
func prinfLikeFuncf (format string , args ... interface {}) {}
19
19
20
+ func prinfLikeFuncWithReturnValue (format string , args ... interface {}) string {
21
+ return ""
22
+ }
23
+
24
+ func prinfLikeFuncWithAnotherFormatArgName (msg string , args ... interface {}) {}
25
+
20
26
func prinfLikeFunc (format string , args ... interface {}) {} // want "printf-like formatting function"
21
27
22
28
func prinfLikeFuncWithExtraArgs1 (extraArg , format string , args ... interface {}) {} // want "printf-like formatting function"
23
29
24
30
func prinfLikeFuncWithExtraArgs2 (extraArg int , format string , args ... interface {}) {} // want "printf-like formatting function"
25
-
26
- func prinfLikeFuncWithReturnValue (format string , args ... interface {}) string { // want "printf-like formatting function"
27
- return ""
28
- }
You can’t perform that action at this time.
0 commit comments