From 56ecd1e91783f5f941cc550f234c2fbf5448b46a Mon Sep 17 00:00:00 2001 From: Artur Khantimirov Date: Wed, 16 Jun 2021 08:27:51 +1200 Subject: [PATCH] fix: ignore `.WithStack` and `.WithMessagef` from github.com/pkg/errors (#15) --- README.md | 2 ++ wrapcheck/testdata/ignore_pkg_errors/main.go | 10 +++++++++- wrapcheck/wrapcheck.go | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 70e0d4c..5b18cde 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,8 @@ ignoreSigs: - .Wrap( - .Wrapf( - .WithMessage( +- .WithMessagef( +- .WithStack( ``` ## Usage diff --git a/wrapcheck/testdata/ignore_pkg_errors/main.go b/wrapcheck/testdata/ignore_pkg_errors/main.go index 488322b..87a9634 100644 --- a/wrapcheck/testdata/ignore_pkg_errors/main.go +++ b/wrapcheck/testdata/ignore_pkg_errors/main.go @@ -24,5 +24,13 @@ func do() error { return errors.WithMessage(err, "uh oh") } - return nil + if err != nil { + return errors.WithMessagef(err, "uh %s", "oh") + } + + if err != nil { + return errors.WithStack(err) + } + + return errors.New("uh oh") } diff --git a/wrapcheck/wrapcheck.go b/wrapcheck/wrapcheck.go index 67917f1..9a1a0a0 100644 --- a/wrapcheck/wrapcheck.go +++ b/wrapcheck/wrapcheck.go @@ -16,6 +16,8 @@ var DefaultIgnoreSigs = []string{ ".Wrap(", ".Wrapf(", ".WithMessage(", + ".WithMessagef(", + ".WithStack(", } // WrapcheckConfig is the set of configuration values which configure the