diagnostic

package
v0.0.0-...-bc9eae6 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package diagnostic provides product-neutral diagnostic records and helpers.

Index

Constants

View Source
const (
	SeverityError    = "error"
	SeverityWarning  = "warning"
	SeverityInfo     = "info"
	SeverityBlocking = "blocking"
	SeverityAdvisory = "advisory"
)

Variables

This section is empty.

Functions

func Compare

func Compare(a, b Record) int

Compare orders normalized or unnormalized diagnostic records deterministically.

func HasErrors

func HasErrors(records []Record) bool

HasErrors reports whether records contains any blocking/error diagnostic.

func IsError

func IsError(severity string) bool

IsError reports whether severity should block successful validation.

func NormalizeSeverity

func NormalizeSeverity(severity string) string

NormalizeSeverity returns a stable lowercase severity. Empty and unknown severities are treated as warnings, which is the safest non-success default.

Types

type Location

type Location struct {
	Path          string `json:"path,omitempty"`
	Line          int    `json:"line,omitempty"`
	Column        int    `json:"column,omitempty"`
	Address       string `json:"address,omitempty"`
	ModuleAddress string `json:"module_address,omitempty"`
	APISourceKind string `json:"api_source_kind,omitempty"`
	APISourceID   string `json:"api_source_id,omitempty"`
	OperationID   string `json:"operation_id,omitempty"`
	Field         string `json:"field,omitempty"`
}

Location identifies the artifact, resource, source, or field tied to a diagnostic without requiring a product-specific type.

type Record

type Record struct {
	Code        string         `json:"code"`
	Severity    string         `json:"severity"`
	Message     string         `json:"message"`
	Location    Location       `json:"location,omitempty"`
	Remediation string         `json:"remediation,omitempty"`
	Detail      map[string]any `json:"detail,omitempty"`
}

Record describes one validation, review, authoring, or runtime evidence issue in a product-neutral shape.

func Normalize

func Normalize(record Record) Record

Normalize returns a trimmed copy of record with normalized severity.

func NormalizeAll

func NormalizeAll(records []Record) []Record

NormalizeAll returns normalized records without mutating the input slice.

func Sort

func Sort(records []Record) []Record

Sort returns normalized diagnostics ordered by severity rank, code, location, message, remediation, and detail.

Jump to

Keyboard shortcuts

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