Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update readme and rule names #20

Merged
merged 1 commit into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 | |
2 changes: 1 addition & 1 deletion multipleerrors/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

var Analyzer = &analysis.Analyzer{
Name: "multipleerrors",
Name: "multipleErrors",
Doc: "detects senseless / uncommon use of error concatenations",
Run: run,
}
Expand Down
2 changes: 1 addition & 1 deletion nodiscarderror/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

var Analyzer = &analysis.Analyzer{
Name: "nodiscarderror",
Name: "noDiscardError",
Doc: "prevents `if err != nil { return nil }`",
Run: run,
}
Expand Down
2 changes: 1 addition & 1 deletion openfileflag/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion preferfilepath/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion wraperror/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

var Analyzer = &analysis.Analyzer{
Name: "wraperror",
Name: "wrapError",
Doc: "detects senseless error wrapping",
Run: run,
}
Expand Down
Loading