text (the default) and json.
Text Format
The text format is designed for human readability and follows a familiar compiler-style output:Text Format Fields
Each diagnostic line contains:- File path — The file being analyzed (or
<stdin>when reading from standard input) - Line number — The line where the issue was detected (1-based)
- Column number — The column where the issue starts (1-based)
- Severity — Either
warningorerror - Rule name — The identifier of the rule that triggered (in square brackets)
- Message — A description of the issue
Example Text Output
When to Use Text Format
The text format is ideal for:- Local development — Quick feedback while writing SQL
- Terminal output — Easy to read in your shell
- Editor integration — Many editors parse this format automatically
- CI logs — Human-readable output in build logs
JSON Format
The JSON format provides structured output for programmatic consumption:JSON Structure
The JSON output is an array of diagnostic objects:JSON Fields
Each diagnostic object contains:| Field | Type | Description |
|---|---|---|
rule | string | The rule identifier (e.g., select-star) |
message | string | Human-readable description of the issue |
file | string | File path (or <stdin>) |
line | number | Line number (1-based) |
col | number | Column number (1-based) |
severity | string | Either warning or error |
When to Use JSON Format
The JSON format is ideal for:- CI/CD pipelines — Parse results to fail builds or create reports
- Code review tools — Integrate pgvet into GitHub Actions, GitLab CI, etc.
- Custom reporting — Generate HTML reports, charts, or metrics
- Automated workflows — Trigger actions based on specific rules or severities
Parsing JSON Output
Here are examples of parsing pgvet JSON output in different contexts:Bash Script with jq
Count the number of errors:Python Script
Generate a summary report:JavaScript/Node.js
Integrate into a build script:Empty Results
When no issues are found, both formats produce minimal output: Text format: No output (empty) JSON format: An empty array0.