feat: add --json output - #4
Merged
Merged
Conversation
lint.Problem already carried `json:"rule"` and `json:"message"` tags, but nothing ever emitted them. A linter that runs in CI should be able to hand its results to something other than a human, so finish the API the types already declared. Collect results into a Report and render it as either text or JSON, so both formats derive from one structure and cannot disagree about what was found or what the exit code should be. Text output is unchanged, verified byte-for-byte against the previous binary. The payload reports `blocking` separately from `failed`: in warn mode a run has problems but does not fail, and a consumer needs to tell those apart. Empty problem lists marshal as [] rather than null so callers can iterate without a nil check. Adds the first tests for package main, covering the JSON shape as a CLI contract, the [] guarantee, and the three text renderings. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VSrrciEDBTuFNMtKocScML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
lint.Problemalready carriedjson:"rule"andjson:"message"tags, but nothing ever emitted them. A linter that runs in CI should be able to hand its results to something other than a human, so this finishes the API the types already declared.Design
Results are collected into a
Reportand rendered as either text or JSON, so both formats derive from one structure and can't disagree about what was found or what the exit code should be.Two details worth calling out:
blockingis separate fromfailed. In--mode warna run has problems but doesn't fail. A consumer needs to distinguish "found problems" from "failed the run", andfailed > 0alone can't express that.problemsis always[], nevernull. Callers can iterate without a nil check.Verification
main(1c3a0df) across conforming, violating, warn-mode, and multi-problem-file cases. This was the main regression risk in the refactor.--rangeruns.main, which previously had none — covering the JSON shape as a CLI contract, the[]-not-nullguarantee, and all three text renderings.gofmt,go vet,go test -race ./...clean. Zero third-party dependencies preserved (encoding/jsonis stdlib).Release impact
This is a
feat:, so merging cuts v1.1.0 — not the v1.0.1 discussed earlier. That's the automation working as designed: the version follows the change type. The comment-stripping fix from #1 ships in v1.1.0 along with this.This will also be the first live exercise of
release.ymlvia the merge-to-main path.🤖 Generated with Claude Code
https://claude.ai/code/session_01VSrrciEDBTuFNMtKocScML