uber-go / nilaway

Static analysis tool to detect potential nil panics in Go code
Apache License 2.0
3.17k stars 65 forks source link

`nilaway -V` doesn't work #130

Open dolmen opened 12 months ago

dolmen commented 12 months ago

-V doesn't work. nilaway expects -V=full but this is not what is documented in online help.

$ nilaway 2>&1 | head
nilaway: Run NilAway on this package to report any possible flows of nil values to erroneous sites that our system can detect

Usage: nilaway [-flag] [package]

Flags:
  -V    print version and exit
  -all
        no effect (deprecated)
  -c int
$ nilaway -V         
nilaway: unsupported flag value: -V=true (use -V=full)
$ nilaway -V=full
.../nilaway version devel comments-go-here buildID=352af786e1a1f56351527fa9a903437764e7b54d91fa9d714692ceaebe61e5e8
yuxincs commented 12 months ago

Hey!

The standalone NilAway command is using the singlechecker driver provided by the analysis framework, and these standard flags are set by the library:

https://cs.opensource.google/go/x/tools/+/master:go/analysis/internal/analysisflags/flags.go;l=207-209;drc=559c4300daa4efe55422df9bba86d125cdf1d9ef

Reading from the comments there, this looks like that it's there to satisfy go vet -V protocol.

But I agree the doc should be clearer, we should probably raise an issue for https://github.com/golang/tools

(I have read that they are revamping the driver there: https://github.com/golang/go/issues/61324, which we would use in the future, then we should be able to control the flags ourselves)