This repository was a part of achievement in Internship in Merpay Expert Team.
$ git clone https://github.com/Matts966/genelizer.git && cd genelizer
Now you can edit ./config/sample.hcl
or add other files in ./config
directory to change analysis and
$ YOUR_BINARY_NAME=binary-name make
Then you can get your portable binary named binary-name
!
Or install it in your path by
$ YOUR_BINARY_NAME=binary-name make install
Also Dockerfile is located for test use.
$ make docker
You can read some sample config files, and corresponding test files.
For example, we can ensure closing files by the setting below.
rule "file" {
package = "os"
doc = "check if file is closed"
type "*File" {
should = [ "Close" ]
}
}
Also the generated linter can be tested by the test codes below.
func test10() {
f, _ := os.Open("") // OK
f.Close()
}
func test11() {
_, _ = os.Open("") // want `should call Close when using \*os.File`
}
The golang.org/x/tools/go/analysis
package runs analysis.Analyzer
concurrently per packages using goroutine and waitgroup.
See the code doing it here.
For utilizing this feature of golang.org/x/tools/go/analysis
, genelizer
generates analysis.Analyzer
for each rule in the config.