Skip to content

Commit

Permalink
checkers: rename undefinedFormatting to dynamicFmtString (#1174)
Browse files Browse the repository at this point in the history
  • Loading branch information
quasilyte committed Dec 26, 2021
1 parent a4c828a commit b808007
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions checkers/rules/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,17 +718,17 @@ func emptyDecl(m dsl.Matcher) {
m.Match(`type()`).Report(`empty type() block`)
}

//doc:summary Detects bad usage of fmt.Errorf
//doc:tags diagnostic experimental opinionated
//doc:before fmt.Errorf(xs)
//doc:after fmt.Errorf("%s", xs)
func undefinedFormatting(m dsl.Matcher) {
//doc:summary Detects suspicious formatting strings usage
//doc:tags diagnostic experimental
//doc:before fmt.Errorf(msg)
//doc:after fmt.Errorf("%s", msg)
func dynamicFmtString(m dsl.Matcher) {
m.Match(`fmt.Errorf($f)`).
Where(!m["f"].Const).
Suggest("errors.New($f)").
Report(`use errors.New($f) or fmt.Errorf("%s", $f) instead`)

m.Match(`fmt.Errorf($f($*args))`).
Suggest("errors.New($f($*args))").
Report(`use errors.New($f($*args)) or fmt.Errorf("%s",$f($*args)) instead`)
Report(`use errors.New($f($*args)) or fmt.Errorf("%s", $f($*args)) instead`)
}
24 changes: 12 additions & 12 deletions checkers/rulesdata/rulesdata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b808007

Please sign in to comment.