From 7e6eba377355a40cf9655d36e5a4e1b40940838f Mon Sep 17 00:00:00 2001 From: "Iskander (Alex) Sharipov" Date: Sat, 24 Apr 2021 23:06:01 +0300 Subject: [PATCH] analyzer/testdata: fix emptyStringTest rule for gocritic (#226) Found by @dmitrytrager --- analyzer/testdata/src/gocritic/f1.go | 8 ++++---- analyzer/testdata/src/gocritic/rules.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/analyzer/testdata/src/gocritic/f1.go b/analyzer/testdata/src/gocritic/f1.go index 67a99aeb..0eea7706 100644 --- a/analyzer/testdata/src/gocritic/f1.go +++ b/analyzer/testdata/src/gocritic/f1.go @@ -245,11 +245,11 @@ func newDeref() { func emptyStringTest(s string) { sptr := &s - _ = len(s) == 0 // want `\Qreplace len(s) == 0 with len(s) == ""` - _ = len(s) != 0 // want `\Qreplace len(s) != 0 with len(s) != ""` + _ = len(s) == 0 // want `\Qreplace len(s) == 0 with s == ""` + _ = len(s) != 0 // want `\Qreplace len(s) != 0 with s != ""` - _ = len(*sptr) == 0 // want `\Qreplace len(*sptr) == 0 with len(*sptr) == ""` - _ = len(*sptr) != 0 // want `\Qreplace len(*sptr) != 0 with len(*sptr) != ""` + _ = len(*sptr) == 0 // want `\Qreplace len(*sptr) == 0 with *sptr == ""` + _ = len(*sptr) != 0 // want `\Qreplace len(*sptr) != 0 with *sptr != ""` _ = s == "" _ = s != "" diff --git a/analyzer/testdata/src/gocritic/rules.go b/analyzer/testdata/src/gocritic/rules.go index f5fdb5d4..be565140 100644 --- a/analyzer/testdata/src/gocritic/rules.go +++ b/analyzer/testdata/src/gocritic/rules.go @@ -106,10 +106,10 @@ func testRules(m dsl.Matcher) { m.Match(`len($s) == 0`). Where(m["s"].Type.Is(`string`)). - Report(`replace $$ with len($s) == ""`) + Report(`replace $$ with $s == ""`) m.Match(`len($s) != 0`). Where(m["s"].Type.Is(`string`)). - Report(`replace $$ with len($s) != ""`) + Report(`replace $$ with $s != ""`) m.Match(`$s[len($s)]`). Where(m["s"].Type.Is(`[]$elem`) && m["s"].Pure).