codecharter analyze --output <format> supports four formats.
console (Default)
Human-readable console output with ANSI colors on TTYs.
src/Domain/PricingEngine.cs:42
[warn] DateTime-Direct-Usage
Direct call to DateTime.UtcNow.
Inject TimeProvider via constructor and call GetUtcNow()
Colors are automatically disabled in pipes. Disable manually with --no-color.
json
Structured JSON file with metadata and a findings array.
codecharter analyze MySolution.sln --output json --output-file findings.json
Good for scripting and custom reporting.
sarif
SARIF v2.1, the standard for static analysis tools, consumed natively by GitHub Code Scanning, GitLab SAST, and many IDEs.
codecharter analyze MySolution.sln --output sarif --output-file codecharter.sarif
Example upload to GitHub Code Scanning:
- name: Analyze
run: codecharter analyze MySolution.sln --output sarif --output-file codecharter.sarif
- name: Upload SARIF
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: codecharter.sarif
github-annotations
GitHub annotation format. GitHub Actions runners understand this natively and render findings as inline comments on the PR diff line.
codecharter analyze MySolution.sln --output github-annotations
Output looks like this:
::warning file=src/Domain/PricingEngine.cs,line=42::DateTime-Direct-Usage: Direct call to DateTime.UtcNow
::error file=src/Web/Controllers/ProductsController.cs,line=88::Async-Method-Without-CancellationToken: ...
Use --workspace-root to strip a path prefix if the solution lives in a subdirectory
of the workspace.
The official GitHub Action uses this format internally as the default.
Multiple outputs in one run
--output is repeatable and accepts an optional destination as format:path, so a
single analysis can emit several formats at once — no second run needed:
codecharter analyze MySolution.sln \
--output github-annotations \
--output json:codecharter.json \
--output sarif:codecharter.sarif
Rules:
- stdout formats (
console,github-annotations) take no path and write to stdout; at most one stdout format per run. - file formats (
json,sarif) require a path when combined. - The single-output form is unchanged:
--output <format>(to stdout) and--output <format> --output-file <path>keep working.--output-fileis only for the single-output form and cannot be mixed with theformat:pathsyntax.
This is what the official GitHub Action uses to render
inline annotations while also producing the JSON it parses for the PR comment and its
findings-* outputs (and SARIF when requested) — all from one analysis.
Which format to use when
| Scenario | Format |
|---|---|
| Locally in the console | console |
| GitHub Actions PR annotations | github-annotations |
| GitHub Code Scanning security tab | sarif |
| GitLab SAST | sarif |
| Custom dashboard or script | json |
| Archiving as a CI artifact | json or sarif |