From b2a84462abb6caf2dc1982081c8c1f1bd10c5b61 Mon Sep 17 00:00:00 2001 From: Dean Sheather Date: Tue, 8 Aug 2023 05:32:41 -0700 Subject: [PATCH] chore: fix ruleguard xerrors rules (#8967) --- cli/stat.go | 2 +- scripts/rules.go | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cli/stat.go b/cli/stat.go index 3657a4f3c7..6311596ece 100644 --- a/cli/stat.go +++ b/cli/stat.go @@ -240,7 +240,7 @@ func (*RootCmd) statDisk(s *clistat.Statter) *clibase.Cmd { ds, err := s.Disk(pfx, pathArg) if err != nil { if os.IsNotExist(err) { - // fmt.Errorf produces a more concise error. + //nolint:gocritic // fmt.Errorf produces a more concise error. return fmt.Errorf("not found: %q", pathArg) } return err diff --git a/scripts/rules.go b/scripts/rules.go index 20d0c43f7b..1c26b80704 100644 --- a/scripts/rules.go +++ b/scripts/rules.go @@ -51,8 +51,12 @@ func xerrors(m dsl.Matcher) { m.Import("fmt") m.Import("golang.org/x/xerrors") - m.Match("fmt.Errorf($*args)"). - Suggest("xerrors.New($args)"). + m.Match("fmt.Errorf($arg)"). + Suggest("xerrors.New($arg)"). + Report("Use xerrors to provide additional stacktrace information!") + + m.Match("fmt.Errorf($arg1, $*args)"). + Suggest("xerrors.Errorf($arg1, $args)"). Report("Use xerrors to provide additional stacktrace information!") m.Match("errors.$_($msg)").