Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 27-Sep-2021 | - | ||||
.gitignore | H A D | 27-Sep-2021 | 269 | 16 | 12 | |
.golangci.yml | H A D | 27-Sep-2021 | 5.2 KiB | 150 | 129 | |
.travis.yml | H A D | 27-Sep-2021 | 535 | 25 | 19 | |
LICENSE | H A D | 27-Sep-2021 | 1 KiB | 22 | 17 | |
README.adoc | H A D | 27-Sep-2021 | 2.5 KiB | 75 | 53 | |
comparison.go | H A D | 27-Sep-2021 | 2.5 KiB | 124 | 95 | |
definition.go | H A D | 27-Sep-2021 | 1.4 KiB | 75 | 57 | |
err113.go | H A D | 27-Sep-2021 | 1.7 KiB | 91 | 68 |
README.adoc
1= err113 image:https://godoc.org/github.com/Djarvur/go-err113?status.svg["GoDoc",link="http://godoc.org/github.com/Djarvur/go-err113"] image:https://travis-ci.org/Djarvur/go-err113.svg["Build Status",link="https://travis-ci.org/Djarvur/go-err113"] image:https://coveralls.io/repos/Djarvur/go-err113/badge.svg?branch=master&service=github["Coverage Status",link="https://coveralls.io/github/Djarvur/go-err113?branch=master"] 2Daniel Podolsky 3:toc: 4 5Golang linter to check the errors handling expressions 6 7== Details 8 9Starting from Go 1.13 the standard `error` type behaviour was changed: one `error` could be derived from another with `fmt.Errorf()` method using `%w` format specifier. 10 11So the errors hierarchy could be built for flexible and responsible errors processing. 12 13And to make this possible at least two simple rules should be followed: 14 151. `error` values should not be compared directly but with `errors.Is()` method. 161. `error` should not be created dynamically from scratch but by the wrapping the static (package-level) error. 17 18This linter is checking the code for these 2 rules compliance. 19 20=== Reports 21 22So, `err113` reports every `==` and `!=` comparison for exact `error` type variables except comparison to `nil` and `io.EOF`. 23 24Also, 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. 25 26Note: non-standard packages, like `github.com/pkg/errors` are ignored completely. 27 28== Install 29 30``` 31go get -u github.com/Djarvur/go-err113/cmd/err113 32``` 33 34== Usage 35 36Defined by link:https://pkg.go.dev/golang.org/x/tools/go/analysis/singlechecker[singlechecker] package. 37 38``` 39err113: checks the error handling rules according to the Go 1.13 new error type 40 41Usage: err113 [-flag] [package] 42 43 44Flags: 45 -V print version and exit 46 -all 47 no effect (deprecated) 48 -c int 49 display offending line with this many lines of context (default -1) 50 -cpuprofile string 51 write CPU profile to this file 52 -debug string 53 debug flags, any subset of "fpstv" 54 -fix 55 apply all suggested fixes 56 -flags 57 print analyzer flags in JSON 58 -json 59 emit JSON output 60 -memprofile string 61 write memory profile to this file 62 -source 63 no effect (deprecated) 64 -tags string 65 no effect (deprecated) 66 -trace string 67 write trace log to this file 68 -v no effect (deprecated) 69``` 70 71== Thanks 72 73To link:https://github.com/quasilyte[Iskander (Alex) Sharipov] for the really useful advices. 74 75To link:https://github.com/jackwhelpton[Jack Whelpton] for the bugfix provided.