| 1 | # Handle Malformed Local Codacy JSON |
| 2 | |
| 3 | Use this when `analyze-local.sh` writes a `local-*.json` file but `jq` cannot |
| 4 | parse it. |
| 5 | |
| 6 | 1. Verify the dump before reading it as findings: |
| 7 | |
| 8 | ```bash |
| 9 | jq empty .local/audits/codacy/local-*.json |
| 10 | ``` |
| 11 | |
| 12 | 2. If parsing fails, inspect the first lines: |
| 13 | |
| 14 | ```bash |
| 15 | sed -n '1,80p' .local/audits/codacy/local-*.json |
| 16 | ``` |
| 17 | |
| 18 | 3. Treat tool-runner logs as a local-analysis failure, not as Codacy findings. |
| 19 | A known failure mode is a Dockerized tool trying to read `/.codacyrc` as a |
| 20 | file and reporting `read /.codacyrc: is a directory`. |
| 21 | |
| 22 | 4. Check GitHub check-run annotations: |
| 23 | |
| 24 | ```bash |
| 25 | gh api repos/netdata/netdata/check-runs/<CHECK_RUN_ID>/annotations --paginate |
| 26 | ``` |
| 27 | |
| 28 | 5. If annotations are empty, fetch PR issues through the Codacy API: |
| 29 | |
| 30 | ```bash |
| 31 | .agents/skills/codacy-audit/scripts/pr-issues.sh <PR_NUMBER> |
| 32 | ``` |
| 33 | |
| 34 | 6. If `CODACY_TOKEN` is not configured, record that Codacy details are not |
| 35 | locally available and re-check after the next push. |