diff --git a/README.md b/README.md index ce71cbb..72367aa 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,16 @@ # :ghost: gost -gost is a toy project where I +gost is a static checker for Golang. It contains aggressive rules that aren't afraid false-positive as long as diagnostics are informative. -- experimentally implement static code checkers for Golang -- try the checkers into popular projects to find possible false-positives, insights and bugs +# Installation -## Usage +I recommend to use gost via [reviewdog](https://github.com/reviewdog/reviewdog). +Complete example configuration: -NOTE: It's just note for myself. This is an experimental project so I don't recommend to utilize it. +- [.reviewdog.yml](./reviewdog.yml) +- [.github/workflows/reviewdog.yml](./.github/workflows/reviewdog.yml) + +To run it locally, run following: ```sh # install @@ -16,3 +19,14 @@ go install github.com/seiyab/gost@latest # run go vet -vettool="$(which gost)" ./... ``` + +# Analyzers + +| name | description | practical discovery | +| :------------- | :--------------------------------------------------------------------------- | :---------------------------------------------- | +| closeCloser | report that closer isn't closed | | +| multipleErrors | report suspicious error concatenation | https://github.com/opentofu/opentofu/issues/539 | +| noDiscardError | report that error is discarded | https://github.com/cli/cli/issues/8026 | +| openFileFlag | report suspicious combination of flags in `os.OpenFile()` | https://github.com/anchore/go-logger/pull/13 | +| preferFilepath | report misuse of `"path"` package where `"path/filepath"` should be suitable | https://github.com/anchore/grype/pull/1767 | +| wrapError | report senseless error wrapping | | diff --git a/multipleerrors/analyzer.go b/multipleerrors/analyzer.go index 676172c..b699e2a 100644 --- a/multipleerrors/analyzer.go +++ b/multipleerrors/analyzer.go @@ -10,7 +10,7 @@ import ( ) var Analyzer = &analysis.Analyzer{ - Name: "multipleerrors", + Name: "multipleErrors", Doc: "detects senseless / uncommon use of error concatenations", Run: run, } diff --git a/nodiscarderror/analyzer.go b/nodiscarderror/analyzer.go index c4da034..4e04879 100644 --- a/nodiscarderror/analyzer.go +++ b/nodiscarderror/analyzer.go @@ -10,7 +10,7 @@ import ( ) var Analyzer = &analysis.Analyzer{ - Name: "nodiscarderror", + Name: "noDiscardError", Doc: "prevents `if err != nil { return nil }`", Run: run, } diff --git a/openfileflag/analyzer.go b/openfileflag/analyzer.go index 1510284..71b4afb 100644 --- a/openfileflag/analyzer.go +++ b/openfileflag/analyzer.go @@ -9,7 +9,7 @@ import ( ) var Analyzer = &analysis.Analyzer{ - Name: "openfileflag", + Name: "openFileFlag", Doc: "prevents forgetting to specify O_TRUNC / O_APPEND / O_EXCL flags", Run: run, } diff --git a/preferfilepath/analyzer.go b/preferfilepath/analyzer.go index c86f9c5..55e75ae 100644 --- a/preferfilepath/analyzer.go +++ b/preferfilepath/analyzer.go @@ -10,7 +10,7 @@ import ( ) var Analyzer = &analysis.Analyzer{ - Name: "preferfilepath", + Name: "preferFilepath", Doc: "warn when using path where path/filepath should be suitable", Run: run, Requires: []*analysis.Analyzer{buildssa.Analyzer}, diff --git a/wraperror/analyzer.go b/wraperror/analyzer.go index a52e5bd..24101e5 100644 --- a/wraperror/analyzer.go +++ b/wraperror/analyzer.go @@ -8,7 +8,7 @@ import ( ) var Analyzer = &analysis.Analyzer{ - Name: "wraperror", + Name: "wrapError", Doc: "detects senseless error wrapping", Run: run, }