Skip to content

Commit

Permalink
analyzer: make string concatenation optional
Browse files Browse the repository at this point in the history
  • Loading branch information
catenacyber committed Feb 8, 2024
1 parent 94b53d9 commit b66013f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type perfSprint struct {
errorf bool
sprintf1 bool
fiximports bool
strconcat bool
}

func newPerfSprint() *perfSprint {
Expand All @@ -31,6 +32,7 @@ func newPerfSprint() *perfSprint {
errorf: true,
sprintf1: true,
fiximports: true,
strconcat: true,
}
}

Expand All @@ -47,6 +49,7 @@ func New() *analysis.Analyzer {
r.Flags.BoolVar(&n.errorf, "errorf", true, "optimizes fmt.Errorf")
r.Flags.BoolVar(&n.sprintf1, "sprintf1", true, "optimizes fmt.Sprintf with only one argument")
r.Flags.BoolVar(&n.fiximports, "fiximports", true, "fix needed imports from other fixes")
r.Flags.BoolVar(&n.strconcat, "strconcat", true, "optimizes into strings concatenation")
return r
}

Expand Down Expand Up @@ -143,7 +146,7 @@ func (n *perfSprint) run(pass *analysis.Pass) (interface{}, error) {

switch verb {
default:
if fn == "fmt.Sprintf" && isConcatable(verb) {
if fn == "fmt.Sprintf" && isConcatable(verb) && n.strconcat {
break
}
return
Expand Down

0 comments on commit b66013f

Please sign in to comment.