report

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package report represents the outcome of validating a plugin or marketplace manifest. A Report is a file-level container of Findings; each Finding names a single rule violation with enough context that a human or CI can act on it without reading the source.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Finding

type Finding struct {
	// Severity is error or warning.
	Severity Severity `json:"severity"`
	// Rule is a short machine-readable identifier, e.g. "HANKO001".
	// Stable across releases so CI scripts can pin on it.
	Rule string `json:"rule"`
	// Path is a JSON Pointer into the manifest ("/name", "/plugins/0/source"),
	// or empty when the rule is file-level.
	Path string `json:"path,omitempty"`
	// Message describes what's wrong in one sentence.
	Message string `json:"message"`
	// Fix is a one-line human-readable suggestion. Optional.
	Fix string `json:"fix,omitempty"`
	// DocURL points at the authoritative docs for the rule. Optional.
	DocURL string `json:"doc_url,omitempty"`
}

Finding is a single rule violation.

type Report

type Report struct {
	// File is the path that was validated.
	File string `json:"file"`
	// Kind identifies which schema was applied ("plugin" or "marketplace").
	Kind string `json:"kind"`
	// Marketplace is the --marketplace flag value if any marketplace-specific
	// rules were layered on top of the base schema. Empty otherwise.
	Marketplace string `json:"marketplace,omitempty"`
	// Findings is the ordered list of rule violations.
	Findings []Finding `json:"findings"`
}

Report is a file-level aggregation of findings.

func (*Report) Add

func (r *Report) Add(f Finding)

Add appends a finding.

func (*Report) Counts

func (r *Report) Counts() (errors, warnings int)

Counts returns the number of errors and warnings.

func (*Report) HasErrors

func (r *Report) HasErrors() bool

HasErrors returns true if any finding is SeverityError. This is what drives the CLI exit code.

func (*Report) HasFindings

func (r *Report) HasFindings() bool

HasFindings returns true if the report contains at least one finding of any severity.

func (*Report) WriteJSON

func (r *Report) WriteJSON(w io.Writer) error

WriteJSON emits a stable JSON representation suitable for CI. One object per line is NOT used — a single object is easier to parse with `jq` and aligns with tools like eslint/--format json.

func (*Report) WritePretty

func (r *Report) WritePretty(w io.Writer, color bool)

WritePretty emits a human-readable report. It groups findings by file and severity, using color escapes only when the caller has asked for them (the CLI detects a TTY and decides).

type Severity

type Severity int

Severity classifies how seriously a Finding should be taken.

const (
	// SeverityWarning marks advisory issues. Strict mode can promote
	// these to errors; lenient mode always tolerates them.
	SeverityWarning Severity = iota
	// SeverityError marks issues that block submission. Always fails
	// the CLI exit code.
	SeverityError
)

func (Severity) MarshalJSON

func (s Severity) MarshalJSON() ([]byte, error)

MarshalJSON emits the string form. CI consumers (including the bundled GitHub Action) compare `severity == "error"`, so the default int marshaling of the underlying type would silently break every consumer.

func (Severity) String

func (s Severity) String() string

String returns a lowercase tag used in CLI output and JSON.

func (*Severity) UnmarshalJSON

func (s *Severity) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts the string form emitted by MarshalJSON so the report JSON can round-trip through external tooling.

Jump to

Keyboard shortcuts

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