Skip to content

refactor(output): move lint rendering into internal/output/lint - #81

Merged
TFM-HITESH merged 5 commits into
envaar:mainfrom
TFM-HITESH:refactor/output-lint-rendering
Aug 1, 2026
Merged

TFM-HITESH merged 5 commits into
envaar:mainfrom
TFM-HITESH:refactor/output-lint-rendering

Conversation

@TFM-HITESH

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

Copy link
Copy Markdown
Contributor

Summary

Move lint text and JSON rendering into the layered internal/output/lint package.

Why

This establishes the output boundary described in Discussion #58 and keeps CLI orchestration separate from typed result rendering.

Closes #70.

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 internal/output/lint for lint text and JSON rendering.
  • Updated the lint CLI to use the new output adapter.
  • Converted internal/report into a temporary forwarding compatibility facade.
  • Added exact-output tests for text, fixed findings, JSON, and empty results.

User-visible changes

None. Existing lint output, JSON schema, exit codes, fix markers, and output-file behavior are unchanged.

Validation

Commands run:

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

Additional commands:

go vet ./...
make build
go test ./internal/output/lint ./internal/report ./internal/cli

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **Bug Fixes**
  * Improved lint result formatting for text and JSON output.
  * Fixed JSON output to consistently represent no findings as an empty array.
  * Clearly marks findings that were fixed in text output.
  * Ensured lint findings render consistently across supported output formats.

* **Tests**
  * Added coverage for empty, populated, fixed, and JSON-formatted lint results.
  * Verified output behavior for cases with no findings.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

@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: 79aaa8a3-3eeb-4846-8e88-60a1014bd189

📥 Commits

Reviewing files that changed from the base of the PR and between b8aed7c and f26c310.

📒 Files selected for processing (2)
  • internal/output/lint/lint.go
  • internal/output/lint/lint_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/output/lint/lint.go

📝 Walkthrough

Walkthrough

The PR adds internal/output/lint for text and JSON lint rendering. The lint CLI uses these renderers. The existing internal/report APIs delegate to the new package. Tests cover formatting, JSON output, nil findings, and CLI wiring.

Changes

Lint output migration

Layer / File(s) Summary
Lint renderers and validation
internal/output/doc.go, internal/output/lint/*
Adds text and JSON renderers for lint findings, fixed-finding markers, empty output handling, nil-slice normalization, and focused tests.
CLI integration and compatibility facade
internal/cli/lint.go, internal/report/*, internal/output/lint/lint_test.go
Routes CLI output through internal/output/lint while preserving internal/report APIs through delegation. The tests verify the new import path.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

Possibly related PRs

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 and concisely describes moving lint rendering into the new output package.
Linked Issues check ✅ Passed The changes implement the linked issue objectives, including renderer relocation, CLI wiring, compatibility forwarding, and output-preservation tests.
Out of Scope Changes check ✅ Passed The changes remain within scope and do not introduce unrelated behavior, rule logic, schema, or exit-code changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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.

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
internal/output/lint/lint.go (1)

24-35: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Write the formatted finding directly to builder.

Line 32 creates an intermediate string and violates staticcheck QF1012. Use fmt.Fprintf to write directly to builder.

Proposed fix
-		builder.WriteString(fmt.Sprintf("%s %s %s:%d %s", finding.Severity, finding.Rule, finding.File, finding.Line, finding.Message))
+		fmt.Fprintf(&builder, "%s %s %s:%d %s", finding.Severity, finding.Rule, finding.File, finding.Line, finding.Message)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/output/lint/lint.go` around lines 24 - 35, Update the findings
formatting loop to replace the intermediate fmt.Sprintf call with fmt.Fprintf
writing directly to builder, while preserving the existing finding fields,
prefix, separators, and trailing newline behavior.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/output/lint/lint.go`:
- Around line 24-35: Update the findings formatting loop to replace the
intermediate fmt.Sprintf call with fmt.Fprintf writing directly to builder,
while preserving the existing finding fields, prefix, separators, and trailing
newline behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b8bd953b-9e46-4f2a-bedf-1c4455e79d1f

📥 Commits

Reviewing files that changed from the base of the PR and between f8cc24c and b8aed7c.

📒 Files selected for processing (6)
  • internal/cli/lint.go
  • internal/output/doc.go
  • internal/output/lint/lint.go
  • internal/output/lint/lint_test.go
  • internal/report/json.go
  • internal/report/text.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

This PR refactors lint output rendering by moving the text and JSON renderers from internal/report into a new layered output adapter at internal/output/lint, keeping CLI orchestration separate from typed result rendering while preserving existing output formats and behavior.

Changes:

  • Added internal/output and internal/output/lint to own lint text + JSON rendering.
  • Updated internal/cli/lint.go to render lint results via the new output adapter.
  • Converted internal/report into a forwarding compatibility facade and added exact-output tests for the new renderer.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/report/text.go Turns report.Text into a forwarding wrapper to the new output adapter.
internal/report/json.go Adds compatibility-facade package docs and forwards report.JSON to the new output adapter.
internal/output/lint/lint.go New canonical implementation of lint text and JSON rendering.
internal/output/lint/lint_test.go Adds exact-output tests for the new renderer (and should include an import-path regression check).
internal/output/doc.go Introduces the internal/output root package documentation.
internal/cli/lint.go Switches lint CLI rendering to internal/output/lint for both text and JSON modes.

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

Comment thread internal/output/lint/lint_test.go

@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: 86311b5432

ℹ️ 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/lint/lint_test.go Outdated

@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: f26c3105b3

ℹ️ 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/report/json.go
@TFM-HITESH
TFM-HITESH merged commit 5db9ddc 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 lint rendering into internal/output/lint

2 participants