Documentation
¶
Overview ¶
Package model defines the normalized coverage model that cover100 collects from every supported language and hands to the treemap UI.
The model is deliberately language-neutral: collectors (internal/gocov, internal/tscov) produce FileCoverage values, and aggregation (internal/aggregate) rolls them up into a single Node tree whose shape is repository -> package -> file -> function.
Index ¶
Constants ¶
const ( TypeRoot = "root" TypeRepository = "repository" TypePackage = "package" TypeFile = "file" TypeFunction = "function" )
Node types. The tree is always repository -> package -> file -> function; the root node is the synthetic parent of every repository.
const ( LangGo = "go" LangTypeScript = "typescript" LangJavaScript = "javascript" LangMixed = "mixed" )
Languages reported per node and used by the UI's language filter.
Variables ¶
var MetricNames = []string{"lines", "functions", "files", "packages", "repositories"}
MetricNames is the canonical metric order exposed in the report and UI.
Functions ¶
Types ¶
type FileCoverage ¶
type FileCoverage struct {
Path string
Language string
Lines Metric
Branches *Metric
Functions Metric
FunctionsAvailable bool
FunctionList []FuncCoverage
}
FileCoverage is a collector's result for a single source file. Path is always relative to the scan root and slash-separated, which is what makes node IDs globally unique without a per-collector naming scheme.
type FuncCoverage ¶
FuncCoverage is per-function detail collected from a language that can supply it (currently Istanbul-format JavaScript/TypeScript reports).
type Metric ¶
Metric is a covered/total pair for a single coverage dimension.
type Metrics ¶
type Metrics struct {
Lines Metric `json:"lines"`
Functions Metric `json:"functions"`
Files Metric `json:"files"`
Packages Metric `json:"packages"`
Repositories Metric `json:"repositories"`
}
Metrics groups the five coverage dimensions reported for every tree node.
type Node ¶
type Node struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
// Language is nil on the root node and "mixed" for a repository that holds
// more than one language.
Language *string `json:"language"`
// Path is relative to the repository root for packages and files, and
// relative to the scan root for repositories.
Path string `json:"path,omitempty"`
// Function-only detail.
Line *int `json:"line,omitempty"`
Hits *int `json:"hits,omitempty"`
Covered *bool `json:"covered,omitempty"`
// FunctionsAvailable is present (and false) on Go files: Go's cover
// profiles carry no function-level data, so functions are reported 0/0.
FunctionsAvailable *bool `json:"functionsAvailable,omitempty"`
Branches *Metric `json:"branches,omitempty"`
Metrics
Children []*Node `json:"children,omitempty"`
}
Node is one node of the aggregated coverage tree. Metrics is embedded so the five metric objects are serialized inline, exactly as the UI expects.
type Report ¶
type Report struct {
GeneratedAt string `json:"generatedAt"`
Root string `json:"root"`
Metrics []string `json:"metrics"`
Languages []string `json:"languages"`
Tree *Node `json:"tree"`
// Additive fields. Consumers that only understand the contract above can
// ignore them; they exist so the CLI can report partial failures in-band.
Warnings []string `json:"warnings,omitempty"`
Tool string `json:"tool,omitempty"`
}
Report is the document written to --out and fetched by the treemap page.