From c91e71c080b7278f6364502a0101aa0e3d501f22 Mon Sep 17 00:00:00 2001 From: Neal Caffery Date: Thu, 22 Aug 2024 06:01:08 +0800 Subject: [PATCH] add tip for the JSON output (#266) 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. image Co-authored-by: Yuxin Wang --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 9c26c22c..9592f5ee 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,13 @@ Then, run the linter by: nilaway -include-pkgs="," ./... ``` +> [!TIP] +> Disable the `pretty-print` flag when output as JSON: +> ```shell +> nilaway -json -pretty-print=false -include-pkgs="," ./... +> ``` + + ### golangci-lint (>= v1.57.0) NilAway, in its current form, can report false positives. This unfortunately hinders its immediate