codecharter analyze supports four output formats via --output <format>. The flag is
repeatable and accepts an optional destination as format:path, so a single analysis
can emit several formats at once. See Multiple outputs in one run.
console (Default)
Human-readable console output with ANSI colors. Findings are grouped by severity, and the report ends with a summary of counts, analyzed types and methods, and duration.
--- Warning (1) ---
WARN [Testability] Direct DateTime/DateTimeOffset usage instead of TimeProvider
PricingEngine.CalculatePrice
src/Domain/PricingEngine.cs:42
↳ Inject TimeProvider via constructor and call GetUtcNow()
────────────────────────────────────────
1 violation (1 warning)
Analyzed 120 types, 840 methods in 3.2s
Colors are on by default, including when output is piped or redirected. Disable them
with --no-color.
json
Structured JSON with a summary object (violation count, analyzed types and methods,
duration) and a violations array.
codecharter analyze MySolution.sln --output json --output-file findings.json
Without --output-file (or a json:<path> destination), the JSON is written to
stdout, which is handy for piping into tools like jq.
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. The Info severity maps to the SARIF level
note. Each result carries a stable fingerprint so GitHub Code Scanning can track
findings across runs.
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 workflow commands. GitHub Actions runners understand this natively and render findings as annotations on the affected lines in the pull request's "Files changed" view.
codecharter analyze MySolution.sln --output github-annotations
Output looks like this: the severity maps to the command (Error to ::error,
Warning to ::warning, Info to ::notice), the rule name goes into title=,
and the message is the affected entity plus the recommendation.
::warning file=src/Domain/PricingEngine.cs,line=42,col=18,title=Direct DateTime/DateTimeOffset usage instead of TimeProvider::PricingEngine.CalculatePrice — Inject TimeProvider via constructor and call GetUtcNow()
::error file=src/Web/Controllers/ProductsController.cs,line=88,title=Async method without CancellationToken::ProductsController.GetProducts — ...
A one-line summary (CodeCharter: N violation(s) ...) is written to stderr, so stdout
contains only the workflow commands.
Use --workspace-root to strip a path prefix if the solution lives in a subdirectory
of the workspace.
The official GitHub Action runs the CLI with this format.
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. - An invalid combination (unknown format, missing path for a combined file format,
--output-filemixed withformat:path) exits with code 2 and a usage error.
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 |