uber-go / nilaway

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

Better support json format #265

Closed madneal closed 4 months ago

madneal commented 4 months ago

This PR is aimed to provide a better suport for the json format.

Current Issue

For the orginal json flag provided by checker.go, it's impossible to get analysisflags.JSON from nilaway. There is a conflict bettwen the pretty-print and json output currently due to the code https://github.com/uber-go/nilaway/blob/e90288479601315af13b7fdd3ccd6b50c53a8e7c/nilaway.go#L43. As the default conf.PrettyPrint is true, so the output will be messy when try to output as json.

image

Pros

Can use this flag like this:

nilaway -format="json" ./...
CLAassistant commented 4 months ago

CLA assistant check
All committers have signed the CLA.

madneal commented 4 months ago

@yuxincs can u help to review this?

madneal commented 4 months ago

there are still some issues for this PR, I will try to fix them at first.