diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-09-15 18:05:35 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-09-15 19:34:30 +0200 |
| commit | 712de1c63d9db97c81af68cd0dc4372c53d2e57a (patch) | |
| tree | ae1761fec52c3ae4ddd003a4130ddbda8d0a2d69 /vendor/github.com/Djarvur | |
| parent | 298a69c38dd5c8a9bbd7a022e88f4ddbcf885e16 (diff) | |
vendor/github.com/golangci/golangci-lint: update to v1.31
Diffstat (limited to 'vendor/github.com/Djarvur')
| -rw-r--r-- | vendor/github.com/Djarvur/go-err113/README.adoc | 4 | ||||
| -rw-r--r-- | vendor/github.com/Djarvur/go-err113/comparison.go | 34 | ||||
| -rw-r--r-- | vendor/github.com/Djarvur/go-err113/err113.go | 4 |
3 files changed, 26 insertions, 16 deletions
diff --git a/vendor/github.com/Djarvur/go-err113/README.adoc b/vendor/github.com/Djarvur/go-err113/README.adoc index b4c1f4375..b26af4038 100644 --- a/vendor/github.com/Djarvur/go-err113/README.adoc +++ b/vendor/github.com/Djarvur/go-err113/README.adoc @@ -23,7 +23,7 @@ So, `err113` reports every `==` and `!=` comparison for exact `error` type varia Also, any call of `errors.New()` and `fmt.Errorf()` methods are reported except the calls used to initialise package-level variables and the `fmt.Errorf()` calls wrapping the other errors. -Note: non-standard packages, like `github.com/pkg/errors` are ignored complitely. +Note: non-standard packages, like `github.com/pkg/errors` are ignored completely. == Install @@ -71,3 +71,5 @@ Flags: == Thanks To link:https://github.com/quasilyte[Iskander (Alex) Sharipov] for the really useful advices. + +To link:https://github.com/jackwhelpton[Jack Whelpton] for the bugfix provided.
\ No newline at end of file diff --git a/vendor/github.com/Djarvur/go-err113/comparison.go b/vendor/github.com/Djarvur/go-err113/comparison.go index 7e7777df6..0ffe2863c 100644 --- a/vendor/github.com/Djarvur/go-err113/comparison.go +++ b/vendor/github.com/Djarvur/go-err113/comparison.go @@ -21,18 +21,7 @@ func inspectComparision(pass *analysis.Pass, n ast.Node) bool { // nolint: unpar return true } - // check that both left and right hand side are not nil - if pass.TypesInfo.Types[be.X].IsNil() || pass.TypesInfo.Types[be.Y].IsNil() { - return true - } - - // check that both left and right hand side are not io.EOF - if isEOF(be.X, pass.TypesInfo) || isEOF(be.Y, pass.TypesInfo) { - return true - } - - // check that both left and right hand side are errors - if !isError(be.X, pass.TypesInfo) && !isError(be.Y, pass.TypesInfo) { + if !areBothErrors(be.X, be.Y, pass.TypesInfo) { return true } @@ -99,5 +88,24 @@ func asImportedName(ex ast.Expr, info *types.Info) (string, bool) { return "", false } - return ep.Imported().Name(), true + return ep.Imported().Path(), true +} + +func areBothErrors(x, y ast.Expr, typesInfo *types.Info) bool { + // check that both left and right hand side are not nil + if typesInfo.Types[x].IsNil() || typesInfo.Types[y].IsNil() { + return false + } + + // check that both left and right hand side are not io.EOF + if isEOF(x, typesInfo) || isEOF(y, typesInfo) { + return false + } + + // check that both left and right hand side are errors + if !isError(x, typesInfo) && !isError(y, typesInfo) { + return false + } + + return true } diff --git a/vendor/github.com/Djarvur/go-err113/err113.go b/vendor/github.com/Djarvur/go-err113/err113.go index e9d93a7a0..ec4f52ac7 100644 --- a/vendor/github.com/Djarvur/go-err113/err113.go +++ b/vendor/github.com/Djarvur/go-err113/err113.go @@ -10,7 +10,7 @@ import ( "golang.org/x/tools/go/analysis" ) -// NewAnalyzer creates a new analysis.Analyzer instance tuned to run err113 checks +// NewAnalyzer creates a new analysis.Analyzer instance tuned to run err113 checks. func NewAnalyzer() *analysis.Analyzer { return &analysis.Analyzer{ Name: "err113", @@ -35,7 +35,7 @@ func run(pass *analysis.Pass) (interface{}, error) { return nil, nil } -// render returns the pretty-print of the given node +// render returns the pretty-print of the given node. func render(fset *token.FileSet, x interface{}) string { var buf bytes.Buffer if err := printer.Fprint(&buf, fset, x); err != nil { |
