coverage

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package coverage parses a test-coverage report (lcov, Cobertura XML, or JaCoCo XML) into per-file, per-line coverage. The format is auto-detected from the content. Read-only, size-bounded; returns the aggregated measure.CoverageReport plus the raw line map so a caller can compute new-code coverage (changed lines that are covered).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LineCoverage

type LineCoverage map[string]map[int]bool

LineCoverage maps a file path to (line number -> covered). A line present here is an executable line; absent lines are not counted.

func Parse

Parse reads a coverage report file, auto-detects its format, and returns the aggregated report plus the per-line map.

func ParseBytes

func ParseBytes(data []byte) (measure.CoverageReport, LineCoverage, error)

ParseBytes parses coverage data whose format is auto-detected: XML with a <coverage> root is Cobertura, XML with a <report> root is JaCoCo, otherwise the data is treated as lcov.

func (LineCoverage) NewCodePercent

func (lc LineCoverage) NewCodePercent(changed map[string]map[int]bool) (pct float64, ok bool)

NewCodePercent returns the line-coverage percentage over only the changed lines (file -> set), i.e. coverage on new code. changed[file][line] must be true for a changed line. ok=false when no changed line is measurable (so a caller can skip the metric rather than report a misleading 0 or 100).

Jump to

Keyboard shortcuts

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