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 authored and catenacyber committed Nov 20, 2024
1 parent 33099e0 commit f7c1bb9
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,28 +102,20 @@ func (n *perfSprint) run(pass *analysis.Pass) (interface{}, 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 f7c1bb9

Please sign in to comment.