https://github.com/qawatake/decorator
Library: decorator wraps analyzers to supplement the results with additional details
https://github.com/qawatake/decorator
go golang staticanalysis
Last synced: 11 months ago
JSON representation
Library: decorator wraps analyzers to supplement the results with additional details
- Host: GitHub
- URL: https://github.com/qawatake/decorator
- Owner: qawatake
- License: mit
- Created: 2023-10-28T04:58:09.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-28T11:09:29.000Z (over 2 years ago)
- Last Synced: 2025-02-09T07:41:17.231Z (about 1 year ago)
- Topics: go, golang, staticanalysis
- Language: Go
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# decorator
[](https://pkg.go.dev/github.com/qawatake/decorator)
[](https://github.com/qawatake/decorator/actions/workflows/test.yaml)
[](https://codecov.io/gh/qawatake/decorator)
Library `decorator` wraps analyzers to supplement the results with additional details.
Before
```
internal/example/example.go:11:16: nil dereference in field selection
```
After
```
internal/example/example.go:11:16: 😱 nil dereference in field selection (nilness)
```
## How to use
```go
package main
import (
"github.com/qawatake/decorator"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/nilness"
"golang.org/x/tools/go/analysis/unitchecker"
)
func main() {
unitchecker.Main(
decorator.With(
func(a *analysis.Analyzer, d analysis.Diagnostic) analysis.Diagnostic {
d.Message = "😱 " + d.Message + " (" + a.Name + ")"
return d
},
)(nilness.Analyzer),
)
}
```