output

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package output renders findings for people and for machines.

Index

Constants

View Source
const SchemaVersion = 1

SchemaVersion is the current JSON schema version.

Variables

This section is empty.

Functions

func ColourEnabled

func ColourEnabled(w io.Writer) bool

ColourEnabled reports whether ANSI styling is appropriate for a stream, honouring the NO_COLOR convention (https://no-color.org).

func JSON

func JSON(w io.Writer, findings []rules.Finding) error

JSON writes the report. Findings is never null in the output: an empty run produces `[]`, so consumers can iterate without a nil check.

func RulesMarkdown

func RulesMarkdown() string

RulesMarkdown renders the rule reference.

It is generated from the same metadata the engine uses, so the published documentation cannot drift from what the code does. That is the payoff for keeping the citation and rationale in the rule struct rather than in a separate document someone has to remember to update.

func SARIF

func SARIF(w io.Writer, findings []rules.Finding, version string) error

SARIF writes findings in SARIF 2.1.0.

Every registered rule is declared, not only those that fired, so that a consumer can show the full catalogue and so that a rule going quiet between runs does not look like the rule disappearing.

Types

type Human

type Human struct {
	// Colour enables ANSI styling. Callers should set it from a terminal
	// check and the NO_COLOR convention.
	Colour bool
	// Verbose includes each rule's rationale and citation, for a user meeting
	// a rule for the first time.
	Verbose bool
}

Human renders findings grouped by unit, with colour when the destination is a terminal that wants it.

func (Human) Render

func (h Human) Render(w io.Writer, findings []rules.Finding)

Render writes the findings. It returns nothing: rendering failures on a terminal are not worth propagating, and a failed write to a file surfaces when the caller closes it.

type Report

type Report struct {
	// Version is the schema version, so consumers can detect a breaking
	// change rather than guessing.
	Version int `json:"version"`
	// Findings are ordered deterministically: by unit, then line, then rule.
	Findings []rules.Finding `json:"findings"`
	// Summary counts findings by severity, so a consumer need not aggregate.
	Summary Summary `json:"summary"`
}

Report is the stable JSON schema. It is a published contract: fields may be added, but existing ones do not change meaning or type.

type Summary

type Summary struct {
	Errors   int `json:"errors"`
	Warnings int `json:"warnings"`
	Notes    int `json:"notes"`
}

Summary counts findings by severity.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL