vet

package
v1.9.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package vet analyzes evaluated Loom designs and their consuming Go module.

Index

Constants

View Source
const (
	// RuleRouteOutsideDesign identifies routes registered directly on a Loom mux.
	RuleRouteOutsideDesign = "route-outside-design"
	// RuleGeneratedVersionSkew identifies generated output from another Loom version.
	RuleGeneratedVersionSkew = "generated-version-skew"
	// RuleServerErrorFault identifies 5xx errors that are not marked as faults.
	RuleServerErrorFault = "server-error-fault"
	// RuleRetryableError identifies retryable HTTP statuses without retry metadata.
	RuleRetryableError = "retryable-error"
	// RuleDescriptionMinimum identifies index descriptions without a lower bound.
	RuleDescriptionMinimum = "description-minimum"
	// RuleDescriptionRange identifies numeric range descriptions without matching bounds.
	RuleDescriptionRange = "description-range"
	// RuleStringFormat identifies semantic strings without a format or pattern.
	RuleStringFormat = "string-format"
	// RuleNormalizedRange identifies normalized numbers without zero-to-one bounds.
	RuleNormalizedRange = "normalized-range"
)
View Source
const SuppressionMeta = "loom:vet:ignore"

SuppressionMeta is the DSL metadata key used to suppress vet diagnostics.

Variables

This section is empty.

Functions

func WriteReport

func WriteReport(writer io.Writer, report Report, format Format) error

WriteReport renders report using format.

Types

type Diagnostic

type Diagnostic struct {
	Rule     string   `json:"rule"`
	Severity Severity `json:"severity"`
	Message  string   `json:"message"`
	Location Location `json:"location"`
}

Diagnostic is one actionable Loom adoption finding.

type Format

type Format string

Format identifies a supported vet report encoding.

const (
	// FormatText writes diagnostics in a go vet-like line format.
	FormatText Format = "text"
	// FormatJSON writes the Report JSON representation.
	FormatJSON Format = "json"
	// FormatSARIF writes a SARIF 2.1.0 log.
	FormatSARIF Format = "sarif"
)

func ParseFormat

func ParseFormat(value string) (Format, error)

ParseFormat validates a report format name.

type Location

type Location struct {
	Path   string `json:"path"`
	Line   int    `json:"line,omitempty"`
	Column int    `json:"column,omitempty"`
}

Location identifies either a Go source position or an evaluated design path.

type Report

type Report struct {
	Diagnostics []Diagnostic `json:"diagnostics"`
}

Report contains all diagnostics emitted by one vet run.

func Analyze

func Analyze(root *expr.RootExpr, moduleDir string) (Report, error)

Analyze inspects an evaluated design and the Go module rooted at moduleDir.

func (Report) HasDiagnostics

func (r Report) HasDiagnostics() bool

HasDiagnostics reports whether the report contains findings.

func (*Report) Sort

func (r *Report) Sort()

Sort orders diagnostics deterministically by location, severity, rule, and message.

type Severity

type Severity string

Severity classifies the impact of a diagnostic.

const (
	// SeverityError identifies a high-confidence adoption defect.
	SeverityError Severity = "error"
	// SeverityWarning identifies a heuristic design-quality finding.
	SeverityWarning Severity = "warning"
)

Jump to

Keyboard shortcuts

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