Skip to content

Commit

Permalink
checkers: add math.Max and math.Min to dupArg (go-critic#792)
Browse files Browse the repository at this point in the history
Signed-off-by: Iskander Sharipov <[email protected]>
  • Loading branch information
quasilyte authored Feb 2, 2019
1 parent 34c1dc8 commit cbe095d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions checkers/dupArg_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ func init() {
c.matchers = map[string]func(*ast.CallExpr) bool{
"copy": m["(x, x, ...)"],

"math.Max": m["(x, x, ...)"],
"math.Min": m["(x, x, ...)"],

"reflect.Copy": m["(x, x, ...)"],
"reflect.DeepEqual": m["(x, x, ...)"],

Expand Down
7 changes: 7 additions & 0 deletions checkers/testdata/dupArg/positive_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"go/types"
"image"
"image/draw"
"math"
"reflect"
"strings"
)
Expand Down Expand Up @@ -91,4 +92,10 @@ func duplicatedArgs() {
/*! suspicious duplicated args in `draw.Draw(dstImg, area, dstImg, point, op)` */
draw.Draw(dstImg, area, dstImg, point, op)
}

var x float64
/*! suspicious duplicated args in `math.Max(x, x)` */
_ = math.Max(x, x)
/*! suspicious duplicated args in `math.Min(x, x)` */
_ = math.Min(x, x)
}

0 comments on commit cbe095d

Please sign in to comment.