Skip to content

Commit

Permalink
analyzer: remove redundant if stmts
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear committed Nov 19, 2024
1 parent 7f3ce4e commit 6843b28
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,31 +99,23 @@ func (n *perfSprint) run(pass *analysis.Pass) (interface{}, error) {
fn string
verb string
value ast.Expr
err error
err error
)
switch {
case calledObj == fmtErrorfObj && len(call.Args) == 1:
if n.errorf {
fn = "fmt.Errorf"
verb = "%s"
value = call.Args[0]
} else {
return
}
case calledObj == fmtErrorfObj && len(call.Args) == 1 && n.errorf:
fn = "fmt.Errorf"
verb = "%s"
value = call.Args[0]

case calledObj == fmtSprintObj && len(call.Args) == 1:
fn = "fmt.Sprint"
verb = "%v"
value = call.Args[0]

case calledObj == fmtSprintfObj && len(call.Args) == 1:
if n.sprintf1 {
fn = "fmt.Sprintf"
verb = "%s"
value = call.Args[0]
} else {
return
}
case calledObj == fmtSprintfObj && len(call.Args) == 1 && n.sprintf1:
fn = "fmt.Sprintf"
verb = "%s"
value = call.Args[0]

case calledObj == fmtSprintfObj && len(call.Args) == 2:
verbLit, ok := call.Args[0].(*ast.BasicLit)
Expand Down

0 comments on commit 6843b28

Please sign in to comment.