Skip to content

Commit

Permalink
Ignore some strconv functions by default, fixes #27
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy-muehle committed Oct 7, 2022
1 parent 10a50fc commit 86c7103
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ func DefaultConfig() *Config {
},
IgnoredFunctions: []*regexp.Regexp{
regexp.MustCompile(`time.Date`),
regexp.MustCompile(`strconv.FormatInt`),
regexp.MustCompile(`strconv.FormatUint`),
regexp.MustCompile(`strconv.FormatFloat`),
regexp.MustCompile(`strconv.ParseInt`),
regexp.MustCompile(`strconv.ParseUint`),
regexp.MustCompile(`strconv.ParseFloat`),
},
}
}
Expand Down
13 changes: 13 additions & 0 deletions testdata/src/argument/argument.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"math"
"net/http"
"os"
"strconv"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -92,3 +93,15 @@ func foobaz(numbers ...int) {}
func example12() {
foobaz(0, 1, 3, 5, 6) // want "Magic number: 3" "Magic number: 5" "Magic number: 6"
}

func example13() {
strconv.FormatInt(10, 32)
strconv.FormatUint(5, 32)
strconv.FormatFloat(5.0, 'E', -1, 32)
}

func example14() {
_, _ = strconv.ParseInt("10", 10, 64)
_, _ = strconv.ParseUint("5", 10, 64)
_, _ = strconv.ParseFloat("5.0", 32)
}

0 comments on commit 86c7103

Please sign in to comment.