Skip to content

Commit 4180994

Browse files
Yuki ItoCosmin Cojocar
authored andcommitted
Make G201 ignore CallExpr with no args (#262)
1 parent 443f84f commit 4180994

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

rules/sql.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ func (s *sqlStrFormat) Match(n ast.Node, c *gosec.Context) (*gosec.Issue, error)
134134
}
135135
}
136136

137+
// no formatter
138+
if len(node.Args) == 0 {
139+
return nil, nil
140+
}
141+
137142
var formatter string
138143

139144
// concats callexpr arg strings together if needed before regex evaluation

testutils/source.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,14 @@ func main(){
309309
panic(err)
310310
}
311311
defer rows.Close()
312+
}`}, 0}, {[]string{`
313+
package main
314+
import (
315+
"fmt"
316+
)
317+
318+
func main(){
319+
fmt.Sprintln()
312320
}`}, 0}}
313321

314322
// SampleCodeG202 - SQL query string building via string concatenation

0 commit comments

Comments
 (0)