From cbe095dba8d3cebe4166dbe11f116075a7cf8b92 Mon Sep 17 00:00:00 2001 From: "Iskander (Alex) Sharipov" Date: Sat, 2 Feb 2019 17:11:23 +0300 Subject: [PATCH] checkers: add math.Max and math.Min to dupArg (#792) Signed-off-by: Iskander Sharipov --- checkers/dupArg_checker.go | 3 +++ checkers/testdata/dupArg/positive_tests.go | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/checkers/dupArg_checker.go b/checkers/dupArg_checker.go index 3eb885aa4..431522d8b 100644 --- a/checkers/dupArg_checker.go +++ b/checkers/dupArg_checker.go @@ -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, ...)"], diff --git a/checkers/testdata/dupArg/positive_tests.go b/checkers/testdata/dupArg/positive_tests.go index c16d892b4..d2182370b 100644 --- a/checkers/testdata/dupArg/positive_tests.go +++ b/checkers/testdata/dupArg/positive_tests.go @@ -5,6 +5,7 @@ import ( "go/types" "image" "image/draw" + "math" "reflect" "strings" ) @@ -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) }