coveragepolicy

package
v11.3.24 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package coveragepolicy validates repository coverage against an expiring, machine-readable exception policy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(policy Policy, coverage Coverage, packages []Package, today time.Time) error

Validate enforces aggregate and non-main library floors and validates that every exception is necessary, matched, unexpired, and above its temporary minimum.

Types

type Counts

type Counts struct {
	Covered int
	Total   int
}

Counts are covered and total statements.

func (Counts) Percent

func (c Counts) Percent() float64

Percent returns statement coverage as a percentage.

type Coverage

type Coverage struct {
	Packages map[string]Counts
	Total    Counts
}

Coverage contains statement counts from one Go cover profile.

func ParseProfile

func ParseProfile(r io.Reader) (Coverage, error)

ParseProfile reads a Go coverprofile and aggregates statements by package.

type Exception

type Exception struct {
	Kind      string  `json:"kind"`
	Target    string  `json:"target"`
	Minimum   float64 `json:"minimum"`
	Owner     string  `json:"owner"`
	Rationale string  `json:"rationale"`
	Expires   string  `json:"expires"`
}

Exception temporarily lowers the floor for one exact library package.

type Package

type Package struct {
	ImportPath string
	Name       string
}

Package describes a package returned by go list.

type Policy

type Policy struct {
	SchemaVersion    int         `json:"schema_version"`
	Module           string      `json:"module"`
	AggregateMinimum float64     `json:"aggregate_minimum"`
	LibraryMinimum   float64     `json:"library_minimum"`
	Exceptions       []Exception `json:"exceptions"`
}

Policy is the strict JSON schema consumed by scripts/check-coverage.sh.

func LoadPolicy

func LoadPolicy(filename string) (Policy, error)

LoadPolicy decodes policy with unknown-field rejection.

Jump to

Keyboard shortcuts

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