Skip to content

refactor(diff): move rendering to output layer - #82

Merged
TFM-HITESH merged 1 commit into
envaar:mainfrom
TFM-HITESH:refactor/output-diff-rendering
Aug 1, 2026
Merged

TFM-HITESH merged 1 commit into
envaar:mainfrom
TFM-HITESH:refactor/output-diff-rendering

Conversation

@TFM-HITESH

@TFM-HITESH TFM-HITESH commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Move vaar diff text and JSON rendering into internal/output/diff and remove the obsolete internal/report compatibility facade.

Why

This completes the existing diff output migration described in Discussion #58 and keeps CLI orchestration separate from typed output rendering.

Closes #71.

Type

  • Bug fix
  • New rule
  • Parser change/fix
  • Reporter change/fix
  • Documentation
  • CI / Release
  • Build
  • Performance improvement/change
  • Internal refactor
  • Hotfix

Breaking change

  • No
  • Yes (describe required migration)

Changes

  • Added typed text and JSON renderers under internal/output/diff.
  • Updated the diff CLI to delegate rendering to the output layer.
  • Removed diff formatting and JSON DTO ownership from internal/cli.
  • Deleted the obsolete internal/report compatibility facade.
  • Added exact-output, JSON, boundary, and secret-safety tests.

User-visible changes

None. Existing diff output, JSON schema, quiet mode, exit codes, and error behavior are unchanged.

Validation

Commands run:

  • gofmt -w <touched Go files>
  • make lint
  • go test ./...
  • go run ./cmd/vaar lint ...

Additional commands:

go test -trimpath ./...
go vet ./...
make build
go test ./internal/output/diff ./internal/cli ./internal/diff

Tests

  • Added tests
  • Updated existing tests
  • No tests needed (explain)

Documentation

  • Updated documentation
  • Not applicable

Release notes

Moved diff text and JSON rendering into the layered output package and removed the obsolete report facade.

Reviewer notes

Please pay special attention to:

  • Exact preservation of text and JSON output.
  • Empty JSON arrays remaining arrays rather than null.
  • Secret non-disclosure.
  • Preservation of --quiet, exit codes, and operational errors.
  • Complete removal of internal/report.
  • CLI dependency direction toward internal/output/diff.

Checklist

  • PR title follows Conventional Commits
  • Code is formatted
  • Tests pass
  • Documentation is updated (if needed)
  • Release note added (if needed)
  • No real secrets, credentials or sensitive data is included

Summary by CodeRabbit

  • New Features

    • Improved diff output for human-readable and JSON formats.
    • JSON results now consistently represent missing keys with empty arrays when applicable.
    • Diff output preserves difference direction and avoids exposing dotenv values.
  • Bug Fixes

    • Improved messaging for clean results and singular or plural missing keys.
  • Tests

    • Added comprehensive coverage for text and JSON diff rendering, formatting, ordering, and sensitive-value protection.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 480d79cc-045f-4299-89d2-5d26cd859739

📥 Commits

Reviewing files that changed from the base of the PR and between 5db9ddc and 6312393.

📒 Files selected for processing (8)
  • internal/cli/diff.go
  • internal/cli/diff_test.go
  • internal/output/diff/diff.go
  • internal/output/diff/diff_test.go
  • internal/output/doc.go
  • internal/report/json.go
  • internal/report/report_test.go
  • internal/report/text.go
💤 Files with no reviewable changes (3)
  • internal/report/text.go
  • internal/report/report_test.go
  • internal/report/json.go

📝 Walkthrough

Walkthrough

The diff CLI now delegates text and JSON rendering to internal/output/diff. The new package preserves output structure, ordering, empty arrays, and value non-disclosure. The obsolete internal/report compatibility package was removed.

Changes

Diff output migration

Layer / File(s) Summary
Diff renderer implementation
internal/output/diff/...
Adds typed text and JSON renderers with exact formatting, stable missing-key ordering, empty-array normalization, and dotenv value non-disclosure tests.
CLI integration and validation
internal/cli/diff.go, internal/cli/diff_test.go
The CLI delegates rendering to internal/output/diff. Tests verify the import boundary and update the JSON payload helper name.
Output package scope
internal/output/doc.go
Documents the scope of command-specific output subpackages and excludes compatibility facades. The obsolete internal/report package and tests are removed.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

  • Issue 71: Directly tracks moving diff rendering into internal/output/diff and removing internal/report.
  • Issue 70: Covers the broader migration from internal/report to dedicated internal/output packages.

Possibly related PRs

  • envaar/vaar#81: Applies an analogous CLI rendering migration for lint output.
  • envaar/vaar#53: Introduces the internal/diff.Result data consumed by the new renderers.

Suggested reviewers: shreyagupta1202

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: moving diff rendering into the output layer.
Linked Issues check ✅ Passed The changes satisfy issue #71 by moving diff rendering, preserving output behavior, deleting internal/report, and adding required tests.
Out of Scope Changes check ✅ Passed The changes remain within issue #71, including the documented removal of the obsolete internal/report compatibility facade.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6312393ee6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/output/doc.go

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Moves vaar diff rendering responsibilities into the output layer (internal/output/diff) and completes removal of the obsolete internal/report facade, keeping CLI orchestration focused on IO/flags/exit codes while typed renderers own formatting.

Changes:

  • Added internal/output/diff text + JSON renderers for diff.Result (including empty-array normalization for JSON).
  • Updated internal/cli/diff.go to delegate rendering to internal/output/diff.
  • Removed the internal/report compatibility package and its tests; updated internal/output package documentation.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/report/text.go Removed obsolete forwarding facade (lint text).
internal/report/json.go Removed obsolete forwarding facade (lint JSON).
internal/report/report_test.go Removed tests for the deleted internal/report facade.
internal/output/doc.go Clarified output-layer scope (command-specific subpackages like lint/diff).
internal/output/diff/diff.go New diff text/JSON renderers and JSON empty-array normalization.
internal/output/diff/diff_test.go Added exact-output tests for diff text/JSON rendering behavior.
internal/cli/diff.go CLI now delegates diff rendering to internal/output/diff.
internal/cli/diff_test.go Added import-direction guard test and updated JSON payload type in tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@TFM-HITESH
TFM-HITESH merged commit b10dbd7 into envaar:main Aug 1, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(output): move diff rendering into internal/output/diff

2 participants