Skip to content

Commit

Permalink
add tip for the JSON output (#266)
Browse files Browse the repository at this point in the history
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](https://github.com/golang/tools/blob/0e7ccc0478c322a6b32fb9f74ebfc42e4f965ee9/go/analysis/internal/checker/checker.go#L510),
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.
<img width="1303" alt="image"
src="https://github.com/uber-go/nilaway/assets/12164075/4b199a3b-7151-43a8-ba88-12052859ad00">

Co-authored-by: Yuxin Wang <yuxinw@uber.com>
  • Loading branch information
madneal and yuxincs committed Aug 21, 2024
1 parent 56f5ac5 commit c91e71c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ Then, run the linter by:
nilaway -include-pkgs="<YOUR_PKG_PREFIX>,<YOUR_PKG_PREFIX_2>" ./...
```

> [!TIP]
> Disable the `pretty-print` flag when output as JSON:
> ```shell
> nilaway -json -pretty-print=false -include-pkgs="<YOUR_PKG_PREFIX>,<YOUR_PKG_PREFIX_2>" ./...
> ```
### golangci-lint (>= v1.57.0)
NilAway, in its current form, can report false positives. This unfortunately hinders its immediate
Expand Down

0 comments on commit c91e71c

Please sign in to comment.