uber-go / nilaway

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

add tip for the JSON output #266

Closed madneal closed 3 months ago

madneal commented 4 months ago

This PR provides a tip when output as JSON due to the current default pretty-print flag

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
codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 87.60%. Comparing base (56f5ac5) to head (ae7824b). Report is 1 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #266 +/- ## ======================================= Coverage 87.60% 87.60% ======================================= Files 63 63 Lines 7916 7916 ======================================= Hits 6935 6935 Misses 799 799 Partials 182 182 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

madneal commented 4 months ago

@sonalmahajan15 seems some issue with the golden test

sonalmahajan15 commented 4 months ago

@madneal , yes, something seems to be wrong. We'll look into it and merge the PR.

yuxincs commented 3 months ago

Yeah, I think we'll have to wait for https://github.com/golang/go/issues/61324 to have an importable checker API to use.

yuxincs commented 3 months ago

I'm updating your branch since we recently fixed the CI issue, and we'll need those changes in order for CI to pass :)

github-actions[bot] commented 3 months ago

Golden Test

[!NOTE]
✅ NilAway errors reported on standard libraries are identical.

3271 errors on base branch (main, 56f5ac5) 3271 errors on test branch (a747e8e)

yuxincs commented 3 months ago

Thanks @madneal for the contributions!