Skip to content

docs: document vaar lint --output file export behavior - #31

Merged
TFM-HITESH merged 4 commits into
envaar:mainfrom
shreyaGupta1202:docs/lint-output-flag
Jul 16, 2026
Merged

TFM-HITESH merged 4 commits into
envaar:mainfrom
shreyaGupta1202:docs/lint-output-flag

Conversation

@shreyaGupta1202

@shreyaGupta1202 shreyaGupta1202 commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #23

Document vaar lint --output / -o file export behavior across the top-level README, lint docs, usage guide, and vaar lint help text.

Why

vaar lint --output already supports writing JSON reports to a file, but that behavior was not consistently documented or easy to discover. This change makes the flag more visible and explains how it interacts with --json, stdout, exit codes, destination paths, and overwrite safeguards.

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

  • Add a top-level README example for writing JSON lint output to a file.
  • Expand the lint command docs with --output / -o usage, examples, and behavior details.
  • Update the usage guide to call out JSON file export explicitly.
  • Refresh vaar lint CLI help text and examples so they match the documented --output behavior.

User-visible changes

Before, the docs primarily showed:

vaar lint --json

After, the docs and vaar lint --help also show:

vaar lint --json --output=lint-report.json

They now clarify that --output requires --json, writes the JSON report to a file instead of stdout, replaces existing destination files, requires the parent directory to already exist, and still returns lint exit code 1 when findings are present even though the report file is written successfully.

Validation

Commands run:

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

Additional commands:

env GOCACHE=/tmp/go-build-cache make lint
env GOCACHE=/tmp/go-build-cache go test ./...
env GOCACHE=/tmp/go-build-cache go run ./cmd/vaar lint --json --output=/tmp/vaar-lint-report.json --target=examples/basic/.env.example
env GOCACHE=/tmp/go-build-cache go run ./cmd/vaar lint --json --output=/tmp/vaar-lint-report-broken.json --target=examples/broken/.env.example

Tests

  • Added tests
  • Updated existing tests
  • No tests needed (documentation and help text only; no runtime behavior change)

Documentation

  • Updated documentation
  • Not applicable

Release notes

Document vaar lint --output file export usage and clarify its JSON-only, stdout/file, and exit-code behavior in the docs and CLI help.

Reviewer notes

Please sanity-check that the documented --output behavior matches the current CLI implementation, especially:

  • --output requiring --json
  • file output replacing stdout
  • exit code 1 still writing the report when findings exist
  • the guard that prevents writing output over a lint input file

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

Summary by CodeRabbit

  • Documentation
    • Added and updated guidance for exporting vaar lint JSON reports to a file using --output/-o.
    • Documented destination path behavior (relative/absolute), overwrite handling, and directory requirements.
    • Clarified default behavior (JSON to stdout) vs --output (writes to the destination) and explained exit-code outcomes, including pre-report failure scenarios.
    • Refreshed quick-start, usage examples, and command help text to reflect the new flag.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The lint documentation now describes exporting JSON reports with --output/-o, including path behavior and exit codes. README and usage examples demonstrate file output, while CLI help text and examples reflect the expanded lint flag guidance.

Changes

Lint JSON export documentation

Layer / File(s) Summary
Document JSON file output
docs/lint/README.md, README.md, docs/usage.md
Documents --output/-o, JSON file export examples, destination-path behavior, output-path conflicts, and exit-code outcomes across lint guides and quick-start material.

CLI help alignment

Layer / File(s) Summary
Align CLI help examples
internal/cli/lint.go
Updates lint command descriptions and examples to mention JSON export, the --output requirement, shorthand usage, rule selection, and discovery scopes.

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

Possibly related issues

Possibly related PRs

  • envaar/vaar#3 — Covers related --output JSON file-export behavior and lint exit-code documentation.

Suggested reviewers: nitjsefnie

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The main docs updates align with #23, but the requested docs/help/help-lint.md example is not present in the change set. Add the missing docs/help/help-lint.md file-output example and link it to docs/lint/README.md as requested in #23.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the docs-only change to document vaar lint --output file export behavior.
Out of Scope Changes check ✅ Passed The modified files stay within the requested documentation and help-output scope for vaar lint --output.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@docs/usage.md`:
- Line 14: Update the lint command examples in the documentation table so
--output is not shown as a standalone invocation; document it only alongside
--json, or replace the list with the generic vaar lint [flags] form while
preserving the existing lint guide link.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8ac84c52-dc28-47d5-b411-c4a6d5f5e0fd

📥 Commits

Reviewing files that changed from the base of the PR and between 0bbc249 and d79b087.

📒 Files selected for processing (4)
  • README.md
  • docs/lint/README.md
  • docs/usage.md
  • internal/cli/lint.go

Comment thread docs/usage.md Outdated

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 improves discoverability and accuracy of the existing vaar lint --output / -o behavior by documenting JSON-to-file export across user-facing docs and the vaar lint Cobra help text, without changing runtime behavior.

Changes:

  • Add a quick-start example in the root README.md showing --json --output=....
  • Expand docs/lint/README.md with a dedicated --output / -o section describing path/overwrite/stdout/exit-code behavior.
  • Update internal/cli/lint.go help text examples and description to include --output and -o.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
README.md Adds a top-level example for writing the JSON lint report to a file and links to the full lint guide.
internal/cli/lint.go Updates vaar lint help text to mention JSON file export and provides example invocations.
docs/usage.md Adds --output to the command map and calls out JSON-to-file export in common paths.
docs/lint/README.md Adds a full --output / -o reference section and clarifies stdout vs file behavior and exit codes.

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

Comment thread docs/usage.md Outdated
Comment thread internal/cli/lint.go Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
TFM-HITESH
TFM-HITESH previously approved these changes Jul 16, 2026

@TFM-HITESH TFM-HITESH 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.

lgtm

TFM-HITESH
TFM-HITESH previously approved these changes Jul 16, 2026

@TFM-HITESH TFM-HITESH 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.

lgtm

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

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

Comment thread internal/cli/lint.go Outdated

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

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@internal/cli/lint.go`:
- Around line 146-150: Handle the returned errors from all three fmt.Fprintf
calls in the success-reporting branch of the lint command. Check each write
result and immediately return a NewToolError when output to cmd.ErrOrStderr()
fails, while preserving the existing messages and branching for successful
writes.
- Line 28: Remove the runtime behavior introduced by the lintListRules flag and
its --list-rules handling, including success messages written to stderr, from
the docs-only changes. Keep the existing lint execution behavior unchanged and
limit this PR to documentation-related updates.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: eddd096a-51f5-4c22-ab7d-3af2d895f1ed

📥 Commits

Reviewing files that changed from the base of the PR and between 96679d0 and 73ed9c2.

📒 Files selected for processing (3)
  • README.md
  • docs/lint/README.md
  • internal/cli/lint.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • README.md
  • docs/lint/README.md

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

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@internal/cli/lint.go`:
- Around line 146-150: Handle the returned errors from all three fmt.Fprintf
calls in the success-reporting branch of the lint command. Check each write
result and immediately return a NewToolError when output to cmd.ErrOrStderr()
fails, while preserving the existing messages and branching for successful
writes.
- Line 28: Remove the runtime behavior introduced by the lintListRules flag and
its --list-rules handling, including success messages written to stderr, from
the docs-only changes. Keep the existing lint execution behavior unchanged and
limit this PR to documentation-related updates.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: eddd096a-51f5-4c22-ab7d-3af2d895f1ed

📥 Commits

Reviewing files that changed from the base of the PR and between 96679d0 and 73ed9c2.

📒 Files selected for processing (3)
  • README.md
  • docs/lint/README.md
  • internal/cli/lint.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • README.md
  • docs/lint/README.md
🛑 Comments failed to post (2)
internal/cli/lint.go (2)

28-28: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map the target file structure first.
ast-grep outline internal/cli/lint.go --view expanded || true

echo '--- file excerpt ---'
cat -n internal/cli/lint.go | sed -n '1,320p'

Repository: envaar/vaar

Length of output: 9500


Keep this PR runtime-neutral

The new --list-rules path and the stderr success messages change CLI behavior; split those out of this docs-only PR or move them to a separate runtime change.

🤖 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/cli/lint.go` at line 28, Remove the runtime behavior introduced by
the lintListRules flag and its --list-rules handling, including success messages
written to stderr, from the docs-only changes. Keep the existing lint execution
behavior unchanged and limit this PR to documentation-related updates.

146-150: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Handle status-write errors.

The three fmt.Fprintf calls ignore their returned errors. If cmd.ErrOrStderr() fails, the command silently continues instead of reporting the output failure. Check the write result and return a NewToolError when needed.

🧰 Tools
🪛 golangci-lint (2.12.2)

[error] 146-146: Error return value of fmt.Fprintf is not checked

(errcheck)


[error] 148-148: Error return value of fmt.Fprintf is not checked

(errcheck)


[error] 150-150: Error return value of fmt.Fprintf is not checked

(errcheck)

🤖 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/cli/lint.go` around lines 146 - 150, Handle the returned errors from
all three fmt.Fprintf calls in the success-reporting branch of the lint command.
Check each write result and immediately return a NewToolError when output to
cmd.ErrOrStderr() fails, while preserving the existing messages and branching
for successful writes.

Source: Linters/SAST tools

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@TFM-HITESH

Copy link
Copy Markdown
Contributor

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@internal/cli/lint.go`:
- Around line 40-45: Update the lint command help text around the examples so
the heading is “Examples:” rather than introducing --list-rules as the purpose
of all following commands. Keep the --list-rules explanation immediately before
its dedicated example, and retain the other --only, --json, --skip, and target
examples as general usage examples.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a9a00f62-8567-4d01-80d3-839e86abf8d3

📥 Commits

Reviewing files that changed from the base of the PR and between 48441b2 and e71403c.

📒 Files selected for processing (4)
  • README.md
  • docs/lint/README.md
  • docs/usage.md
  • internal/cli/lint.go

Comment thread internal/cli/lint.go
@TFM-HITESH
TFM-HITESH merged commit 2139aff into envaar:main Jul 16, 2026
8 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.

docs: document the lint --output flag

3 participants