Make G201 ignore CallExpr with no args (#262)

This commit is contained in:
Yuki Ito 2018-11-05 17:28:47 +09:00 committed by Cosmin Cojocar
parent 443f84fd4d
commit 41809946d4
2 changed files with 13 additions and 0 deletions

View file

@ -134,6 +134,11 @@ func (s *sqlStrFormat) Match(n ast.Node, c *gosec.Context) (*gosec.Issue, error)
} }
} }
// no formatter
if len(node.Args) == 0 {
return nil, nil
}
var formatter string var formatter string
// concats callexpr arg strings together if needed before regex evaluation // concats callexpr arg strings together if needed before regex evaluation

View file

@ -309,6 +309,14 @@ func main(){
panic(err) panic(err)
} }
defer rows.Close() defer rows.Close()
}`}, 0}, {[]string{`
package main
import (
"fmt"
)
func main(){
fmt.Sprintln()
}`}, 0}} }`}, 0}}
// SampleCodeG202 - SQL query string building via string concatenation // SampleCodeG202 - SQL query string building via string concatenation