model

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package model defines the format-agnostic coverage types that all coverage parsers produce and all coverage renderers consume.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BranchCov

type BranchCov struct {
	Line  int
	Block int
	Index int
	Taken int // -1 = not reachable, 0 = not taken, >0 = taken count
}

BranchCov records one branch outcome (true/false side of a conditional).

type CovReport

type CovReport struct {
	Sources   []string
	Timestamp time.Time
	Files     []*FileCov
}

CovReport is the top-level, format-independent coverage result.

func (*CovReport) BranchPct

func (r *CovReport) BranchPct() float64

BranchPct returns overall branch coverage %.

func (*CovReport) FuncPct

func (r *CovReport) FuncPct() float64

FuncPct returns overall function coverage %.

func (*CovReport) LinePct

func (r *CovReport) LinePct() float64

LinePct returns overall line coverage %.

func (*CovReport) Merge

func (r *CovReport) Merge(other *CovReport)

Merge incorporates all files from other into r. Files with duplicate paths are combined by appending their raw slice data and recomputing totals. Use this to merge per-package coverage profiles into one aggregate report.

func (*CovReport) Stats

func (r *CovReport) Stats() (lt, lc, bt, bc, ft, fc int)

Stats returns aggregate line/branch/function totals across all files.

type FileCov

type FileCov struct {
	Path string // normalised relative path (e.g. "src/core/parser.go")

	Lines    []LineCov
	Branches []BranchCov
	Funcs    []FuncCov

	// Precomputed totals (populated by parsers or via Compute).
	LinesTotal    int
	LinesCovered  int
	BranchTotal   int
	BranchCovered int
	FuncTotal     int
	FuncCovered   int
}

FileCov holds all coverage data for one source file.

func (*FileCov) BranchPct

func (f *FileCov) BranchPct() float64

BranchPct returns branch coverage as a percentage [0, 100].

func (*FileCov) Compute

func (f *FileCov) Compute()

Compute fills the precomputed totals from the raw slice data. Call this after a parser has finished populating Lines/Branches/Funcs.

func (*FileCov) FuncPct

func (f *FileCov) FuncPct() float64

FuncPct returns function coverage as a percentage [0, 100].

func (*FileCov) LinePct

func (f *FileCov) LinePct() float64

LinePct returns line coverage as a percentage [0, 100].

type FuncCov

type FuncCov struct {
	Name  string
	Line  int // declaration line
	Calls int
}

FuncCov records call-count data for one function.

type LineCov

type LineCov struct {
	Number int
	Hits   int // 0 = not covered, >0 = covered
}

LineCov records execution data for a single source line.

Jump to

Keyboard shortcuts

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