Documentation
¶
Overview ¶
Package pattern defines the semantic data types for fo's output visualization. Patterns are pure data — renderers decide presentation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Comparison ¶
type Comparison struct {
Label string
Changes []ComparisonItem
}
Comparison represents before/after metric comparisons.
func (*Comparison) Type ¶
func (c *Comparison) Type() PatternType
type ComparisonItem ¶
type ComparisonItem struct {
Label string
Before string
After string
Change float64 // positive or negative
Unit string // e.g., "%", "MB", "ms"
}
ComparisonItem is a single before/after delta.
type Error ¶
type Error struct {
Source string // tool name or component that failed
Message string // what went wrong
}
Error represents a processing failure (e.g., unparseable section in a report). Distinct from test failures or lint diagnostics — this is fo's own error.
func (*Error) Type ¶
func (e *Error) Type() PatternType
type Leaderboard ¶
type Leaderboard struct {
Label string
MetricName string // e.g., "Issues", "Duration"
Items []LeaderboardItem
Direction string // "highest" or "lowest"
TotalCount int // total before filtering to top N
ShowRank bool
}
Leaderboard represents a ranked list of items by metric.
func (*Leaderboard) Type ¶
func (l *Leaderboard) Type() PatternType
type LeaderboardItem ¶
type LeaderboardItem struct {
Name string // display name
Metric string // formatted value (e.g., "2.3s", "12 warnings")
Value float64 // numeric value for sorting
Rank int
Context string // optional extra context
}
LeaderboardItem is a single ranked entry.
type Pattern ¶
type Pattern interface {
Type() PatternType
}
Pattern is the interface all visualization patterns implement. Patterns hold data; renderers decide how to present it.
type PatternType ¶
type PatternType string
PatternType identifies the kind of visualization pattern.
const ( PatternTypeSummary PatternType = "summary" PatternTypeLeaderboard PatternType = "leaderboard" PatternTypeTestTable PatternType = "test-table" PatternTypeSparkline PatternType = "sparkline" PatternTypeComparison PatternType = "comparison" PatternTypeError PatternType = "error" )
type Sparkline ¶
type Sparkline struct {
Label string
Values []float64
Min float64 // 0 = auto-detect
Max float64 // 0 = auto-detect
Unit string // e.g., "ms", "%", "MB"
}
Sparkline represents a word-sized trend graphic using Unicode blocks.
func (*Sparkline) Type ¶
func (s *Sparkline) Type() PatternType
type Summary ¶
type Summary struct {
Label string
Kind SummaryKind // dispatch key for renderers
Metrics []SummaryItem
}
Summary represents high-level metrics and counts.
func (*Summary) Type ¶
func (s *Summary) Type() PatternType
type SummaryItem ¶
type SummaryItem struct {
Label string // e.g., "Errors", "Warnings", "Passed"
Value string // formatted value
Kind string // "success", "error", "warning", "info" — affects coloring
}
SummaryItem is a single metric in a summary.
type SummaryKind ¶
type SummaryKind string
SummaryKind identifies the source format for dispatch (avoids string-prefix matching).
const ( SummaryKindSARIF SummaryKind = "sarif" SummaryKindTest SummaryKind = "test" SummaryKindReport SummaryKind = "report" )
type TestTable ¶
type TestTable struct {
Label string
Source string // originating tool (set in report context for grouping)
Results []TestTableItem
}
TestTable represents test results with status and timing.
func (*TestTable) Type ¶
func (t *TestTable) Type() PatternType
type TestTableItem ¶
type TestTableItem struct {
Name string // test or package name
Status string // "pass", "fail", "skip"
Duration string // formatted duration
Count int // number of tests (package-level)
Details string // error message or extra info
}
TestTableItem is a single test/package result.