Skip to content

Commit

Permalink
functions: add more pure functions
Browse files Browse the repository at this point in the history
Updates gh-149
  • Loading branch information
dominikh committed Aug 6, 2017
1 parent 2ab10e4 commit 7701ff7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions functions/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ import (
)

var stdlibDescs = map[string]Description{
"errors.New": Description{Pure: true},

"fmt.Errorf": Description{Pure: true},
"fmt.Sprintf": Description{Pure: true},
"fmt.Sprint": Description{Pure: true},

"sort.Reverse": Description{Pure: true},

"strings.Map": Description{Pure: true},
"strings.Repeat": Description{Pure: true},
"strings.Replace": Description{Pure: true},
Expand Down
8 changes: 4 additions & 4 deletions staticcheck/testdata/CheckUnsafePrintf.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
func fn() {
var s string
fn2 := func() string { return "" }
fmt.Printf(fn2()) // MATCH /should use print-style function/
fmt.Sprintf(fn2()) // MATCH /should use print-style function/
log.Printf(fn2()) // MATCH /should use print-style function/
fmt.Printf(s) // MATCH /should use print-style function/
fmt.Printf(fn2()) // MATCH /should use print-style function/
_ = fmt.Sprintf(fn2()) // MATCH /should use print-style function/
log.Printf(fn2()) // MATCH /should use print-style function/
fmt.Printf(s) // MATCH /should use print-style function/
fmt.Printf(s, "")

fmt.Printf(fn2(), "")
Expand Down

0 comments on commit 7701ff7

Please sign in to comment.