coverage

package module
v0.0.0-...-79d4139 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2023 License: BSD-3-Clause Imports: 8 Imported by: 1

README

GO Coverage

go-coverage is a lcov/cobertura parser

Usage

lcovParser := New("./test/lcov.info", LCOV)
report, err := lcovParser.Parse()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloverClass

type CloverClass struct {
	Name    string             `xml:"name,attr"`
	Metrics CloverClassMetrics `xml:"metrics"`
}

type CloverClassMetrics

type CloverClassMetrics struct {
	Complexity          int64   `xml:"complexity,attr"`
	Elements            int64   `xml:"elements,attr"`
	CoveredElements     int64   `xml:"coveredelements,attr"`
	Conditionnals       int64   `xml:"conditionals,attr"`
	CoveredConditionals int64   `xml:"coveredconditionals,attr"`
	Statements          int64   `xml:"statements,attr"`
	CoveredStatements   int64   `xml:"coveredstatements,attr"`
	CoveredMethods      int64   `xml:"coveredmethods,attr"`
	Methods             int64   `xml:"methods,attr"`
	TestDuration        float64 `xml:"testduration,attr"`
	TestFailures        int64   `xml:"testfailures,attr"`
	TestPasses          int64   `xml:"testpasses,attr"`
	TestRuns            int64   `xml:"testruns,attr"`
}

type CloverCoverage

type CloverCoverage struct {
	XMLName   xml.Name      `xml:"coverage"`
	Clover    string        `xml:"clover,attr"`
	Generated int64         `xml:"generated,attr"`
	Project   CloverProject `xml:"project"`
}

type CloverFile

type CloverFile struct {
	Name    string            `xml:"name,attr"`
	Path    string            `xml:"path,attr"`
	Metrics CloverFileMetrics `xml:"metrics"`
	Class   []CloverClass     `xml:"class"`
	Line    []CloverLine      `xml:"line"`
}

type CloverFileMetrics

type CloverFileMetrics struct {
	CloverClassMetrics
	Classes int64 `xml:"classes,attr"`
	Loc     int64 `xml:"loc,attr"`
	Ncloc   int64 `xml:"ncloc,attr"`
}

type CloverLine

type CloverLine struct {
	Num          int64   `xml:"num,attr"`
	Type         string  `xml:"type,attr"`
	Complexity   int64   `xml:"complexity,attr"`
	Count        int64   `xml:"count,attr"`
	FalseCount   int64   `xml:"falsecount,attr"`
	TrueCount    int64   `xml:"truecount,attr"`
	Signature    int64   `xml:"signature,attr"`
	TestDuration float64 `xml:"testduration,attr"`
	TestSuccess  bool    `xml:"testsuccess,attr"`
	Visibility   string  `xml:"visibility,attr"`
}

type CloverMetric

type CloverMetric struct {
	CloverPackageMetrics
	Packages int64 `xml:"packages,attr"`
}

type CloverPackage

type CloverPackage struct {
	Name    string               `xml:"name,attr"`
	Metrics CloverPackageMetrics `xml:"metrics"`
	File    []CloverFile         `xml:"file"`
}

type CloverPackageMetrics

type CloverPackageMetrics struct {
	CloverFileMetrics
	Files int64 `xml:"files,attr"`
}

type CloverProject

type CloverProject struct {
	Name      string          `xml:"name,attr"`
	Timestamp int64           `xml:"timestamp,attr"`
	Metrics   CloverMetric    `xml:"metrics"`
	Package   []CloverPackage `xml:"package"`
}

type CoberturaClass

type CoberturaClass struct {
	Name       string           `xml:"name,attr"`
	FileName   string           `xml:"filename,attr"`
	LineRate   string           `xml:"line-rate,attr"`
	BranchRate string           `xml:"branch-rate,attr"`
	Complexity string           `xml:"complexity,attr"`
	Methods    CoberturaMethods `xml:"methods"`
	Lines      CoberturaLines   `xml:"lines"`
}

type CoberturaClasses

type CoberturaClasses struct {
	Class []CoberturaClass `xml:"class"`
}

type CoberturaCondition

type CoberturaCondition struct {
	Number   string `xml:"number,attr"`
	Type     string `xml:"type,attr"`
	Coverage string `xml:"coverage,attr"`
}

type CoberturaConditions

type CoberturaConditions struct {
	Condition []CoberturaCondition `xml:"conditions,attr"`
}

type CoberturaCoverage

type CoberturaCoverage struct {
	XMLName         xml.Name          `xml:"coverage"`
	LineRate        string            `xml:"line-rate,attr"`
	BranchRate      string            `xml:"branch-rate,attr"`
	LinesCovered    string            `xml:"lines-covered,attr"`
	LinesValid      string            `xml:"lines-valid,attr"`
	BranchesCovered string            `xml:"branches-covered,attr"`
	BranchesValid   string            `xml:"branches-valid,attr"`
	Complexity      string            `xml:"complexity,attr"`
	Version         string            `xml:"version,attr"`
	Timestamp       string            `xml:"timestamp,attr"`
	Sources         CoberturaSources  `xml:"sources"`
	Packages        CoberturaPackages `xml:"packages"`
}

type CoberturaLine

type CoberturaLine struct {
	Number            string `xml:"number,attr"`
	Hits              string `xml:"hits,attr"`
	Branch            string `xml:"branch,attr"`
	ConditionCoverage string `xml:"condition-coverage,attr"`
	Conditions        []CoberturaConditions
}

type CoberturaLines

type CoberturaLines struct {
	Line []CoberturaLine `xml:"line"`
}

type CoberturaMethod

type CoberturaMethod struct {
	Name       string         `xml:"name,attr"`
	Signature  string         `xml:"signature,attr"`
	LineRate   string         `xml:"line-rate,attr"`
	BranchRate string         `xml:"branch-rate,attr"`
	Lines      CoberturaLines `xml:"lines"`
}

type CoberturaMethods

type CoberturaMethods struct {
	Method []CoberturaMethod `xml:"method"`
}

type CoberturaPackage

type CoberturaPackage struct {
	Name       string           `xml:"name,attr"`
	LineRate   string           `xml:"line-rate,attr"`
	BranchRate string           `xml:"branch-rate,attr"`
	Complexity string           `xml:"complexity,attr"`
	Classes    CoberturaClasses `xml:"classes"`
}

type CoberturaPackages

type CoberturaPackages struct {
	Package []CoberturaPackage `xml:"package"`
}

type CoberturaSources

type CoberturaSources struct {
	Source []string `xml:"source"`
}

type CoverageMode

type CoverageMode string

CoverageMode represents the format of the coverage reprt

const (
	LCOV      CoverageMode = "lcov"
	COBERTURA CoverageMode = "cobertura"
	CLOVER    CoverageMode = "clover"
)

type FileReport

type FileReport struct {
	Path             string `json:"path"`
	TotalLines       int    `json:"total_lines"`
	CoveredLines     int    `json:"covered_lines"`
	TotalFunctions   int    `json:"total_functions"`
	CoveredFunctions int    `json:"covered_functions"`
	TotalBranches    int    `json:"total_branches"`
	CoveredBranches  int    `json:"covered_branches"`
}

FileReport contains all informations about a file

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser represents the lcov parser

func New

func New(filePath string, mode CoverageMode) Parser

New creates a new lcov parser

func (Parser) Parse

func (l Parser) Parse() (Report, error)

Parse parses the lcov file

type Report

type Report struct {
	Files            []FileReport `json:"files"`
	TotalLines       int          `json:"total_lines"`
	CoveredLines     int          `json:"covered_lines"`
	TotalFunctions   int          `json:"total_functions"`
	CoveredFunctions int          `json:"covered_functions"`
	TotalBranches    int          `json:"total_branches"`
	CoveredBranches  int          `json:"covered_branches"`
}

Report represents the result of LcovParser.parse

Jump to

Keyboard shortcuts

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