findings

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package findings is the output layer: the findings model, the schema-valid machine document (self-validated through the strictspec findings reader before it is handed to the framework, which validates it again against the declared payload schema), the human-readable text rendering, and the exit-code rule.

Index

Constants

This section is empty.

Variables

View Source
var Schema = strictcli.SchemaObject(
	map[string]interface{}{
		"format_version":     strictcli.SchemaConst(1),
		"strictcode_version": strictcli.SchemaType("string"),
		"workspace_root":     strictcli.SchemaType("string"),
		"findings": strictcli.SchemaArray(strictcli.SchemaObject(
			map[string]interface{}{
				"rule":     strictcli.SchemaType("string"),
				"severity": strictcli.SchemaEnum("error", "warning"),
				"message":  strictcli.SchemaType("string"),
				"target": strictcli.SchemaObject(
					map[string]interface{}{
						"id":   strictcli.SchemaType("string"),
						"kind": strictcli.SchemaEnum(nodeKindValues()...),
						"file": strictcli.SchemaType("string"),
						"line": strictcli.SchemaType("integer"),
					},
					[]string{"id", "kind", "file", "line"},
					false,
				),

				"fix": strictcli.SchemaObject(
					map[string]interface{}{
						"tier":        strictcli.SchemaType("integer"),
						"description": strictcli.SchemaType("string"),
					},
					[]string{"tier", "description"},
					false,
				),
			},
			[]string{"rule", "severity", "message", "target"},
			false,
		)),
	},
	[]string{"format_version", "strictcode_version", "workspace_root", "findings"},
	false,
)

Schema is the analyze command's declared payload schema (strictcli §19.5), the closed-subset statement of the same document schema/strictspec/findings.schema.toml governs. The framework enforces it where it writes the envelope and --dump-schema publishes it, so a consumer has something to generate against without reading the strictspec document.

The target-kind enum is derived from the vocabulary rather than written out, because the vocabulary is where node kinds are declared and a second hand-kept list could only drift from it.

Functions

func FailRun

func FailRun(fs []Finding) bool

FailRun reports whether the findings set fails the run (nonzero exit): any error-severity finding does; warnings alone do not.

func RenderText

func RenderText(fs []Finding) string

RenderText renders the human-readable report: one line per finding (file:line: severity: message [rule]), then a summary.

func Sort

func Sort(fs []Finding)

Sort orders findings deterministically: file, line, rule, target ID, message.

Types

type Document

type Document struct {
	// FormatVersion is the strictspec document version stamp, exact-match
	// checked by the findings schema.
	FormatVersion     int           `json:"format_version"`
	StrictcodeVersion string        `json:"strictcode_version"`
	WorkspaceRoot     string        `json:"workspace_root"`
	Findings          []findingJSON `json:"findings"`
}

Document is the strictcode findings document: the analyze command's machine payload, carried as the envelope's payload member under --json. Its shape is owned by schema/strictspec/findings.schema.toml, which is why it keeps its own format_version and version stamps rather than deferring to the envelope's framing.

func Build

func Build(version, workspaceRoot string, fs []Finding) (Document, error)

Build assembles the findings document (sorted) and self-validates it against the findings schema — an invalid document is a bug and a hard error, never emitted output. The framework validates the same value again against Schema where it writes the envelope; the two duties are different authorities over the same document and both are kept.

type Finding

type Finding struct {
	Rule     string
	Severity rules.Severity
	Message  string
	Target   Target
	Fix      *Fix
}

Finding is one diagnosis instance.

type Fix

type Fix struct {
	Tier        int
	Description string
}

Fix describes the offered fix, when one exists.

type Target

type Target struct {
	// ID is the serialized qualified node ID (schema/SPEC.md section 2).
	ID string
	// Kind is the node kind.
	Kind vocab.NodeKind
	// File is the workspace-root-relative file path.
	File string
	// Line is the 1-based line, derived from the byte span at output time.
	Line int
}

Target is what a finding points at: a node plus its site.

Jump to

Keyboard shortcuts

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