coverage

package
v0.59.3 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const CloverDefaultPath = "coverage.xml"
View Source
const CoberturaDefaultPath = "coverage.xml"
View Source
const GocoverDefaultPath = "coverage.out"

Variables

View Source
var JacocoDefaultPath = []string{"build", "reports", "jacoco", "test", "jacocoTestReport.xml"}
View Source
var LcovDefaultPath = []string{"coverage", "lcov.info"}
View Source
var SimplecovDefaultPath = []string{"coverage", ".resultset.json"}

Functions

This section is empty.

Types

type BlockCoverage

type BlockCoverage struct {
	Type      Type `json:"type"`
	StartLine *int `json:"start_line,omitempty"`
	StartCol  *int `json:"start_col,omitempty"`
	EndLine   *int `json:"end_line,omitempty"`
	EndCol    *int `json:"end_col,omitempty"`
	NumStmt   *int `json:"num_stmt,omitempty"`
	Count     *int `json:"count,omitempty"`
}

type BlockCoverages

type BlockCoverages []*BlockCoverage

func (BlockCoverages) MaxCount

func (bc BlockCoverages) MaxCount() int

func (BlockCoverages) ToLineCoverages

func (bc BlockCoverages) ToLineCoverages() LineCoverages

type Clover

type Clover struct{}

func NewClover

func NewClover() *Clover

func (*Clover) Name

func (c *Clover) Name() string

func (*Clover) ParseReport

func (c *Clover) ParseReport(path string) (*Coverage, string, error)

type CloverReport

type CloverReport struct {
	XMLName   xml.Name             `xml:"coverage"`
	Generated string               `xml:"generated,attr"`
	Project   *CloverReportProject `xml:"project"`
}

type CloverReportFile

type CloverReportFile struct {
	XMLName xml.Name `xml:"file"`
	Name    string   `xml:"name,attr"`
	Metrics struct {
		Loc                 int `xml:"loc,attr"`
		Ncloc               int `xml:"ncloc,attr"`
		Classes             int `xml:"classes,attr"`
		Methods             int `xml:"methods,attr"`
		Coveredmethods      int `xml:"coveredmethods,attr"`
		Conditionals        int `xml:"conditionals,attr"`
		Coveredconditionals int `xml:"coveredconditionals,attr"`
		Statements          int `xml:"statements,attr"`
		Coveredstatements   int `xml:"coveredstatements,attr"`
		Elements            int `xml:"elements,attr"`
		Coveredelements     int `xml:"coveredelements,attr"`
	} `xml:"metrics"`
	Class struct {
		Name      string `xml:"name,attr"`
		Namespace string `xml:"namespace,attr"`
		Metrics   struct {
			Complexity          int `xml:"complexity,attr"`
			Methods             int `xml:"methods,attr"`
			Coveredmethods      int `xml:"coveredmethods,attr"`
			Conditionals        int `xml:"conditionals,attr"`
			Coveredconditionals int `xml:"coveredconditionals,attr"`
			Statements          int `xml:"statements,attr"`
			Coveredstatements   int `xml:"coveredstatements,attr"`
			Elements            int `xml:"elements,attr"`
			Coveredelements     int `xml:"coveredelements,attr"`
		} `xml:"metrics"`
	} `xml:"class"`
	Line []struct {
		Num        int     `xml:"num,attr"`
		Type       string  `xml:"type,attr"`
		Name       string  `xml:"name,attr"`
		Visibility string  `xml:"visibility,attr"`
		Complexity int     `xml:"complexity,attr"`
		Crap       float64 `xml:"crap,attr"`
		Count      int     `xml:"count,attr"`
	} `xml:"line"`
}

type CloverReportPackage

type CloverReportPackage struct {
	XMLName xml.Name           `xml:"package"`
	Name    string             `xml:"name,attr"`
	File    []CloverReportFile `xml:"file"`
}

type CloverReportProject

type CloverReportProject struct {
	Timestamp string                `xml:"timestamp,attr"`
	File      []CloverReportFile    `xml:"file"`
	Package   []CloverReportPackage `xml:"package"`
	Metrics   struct {
		Files               int `xml:"files,attr"`
		Loc                 int `xml:"loc,attr"`
		Ncloc               int `xml:"ncloc,attr"`
		Classes             int `xml:"classes,attr"`
		Methods             int `xml:"methods,attr"`
		Coveredmethods      int `xml:"coveredmethods,attr"`
		Conditionals        int `xml:"conditionals,attr"`
		Coveredconditionals int `xml:"coveredconditionals,attr"`
		Statements          int `xml:"statements,attr"`
		Coveredstatements   int `xml:"coveredstatements,attr"`
		Elements            int `xml:"elements,attr"`
		Coveredelements     int `xml:"coveredelements,attr"`
	} `xml:"metrics"`
}

type Cobertura

type Cobertura struct{}

func NewCobertura

func NewCobertura() *Cobertura

func (*Cobertura) Name

func (c *Cobertura) Name() string

func (*Cobertura) ParseReport

func (c *Cobertura) ParseReport(path string) (*Coverage, string, error)

type CoberturaReport

type CoberturaReport struct {
	XMLName         xml.Name `xml:"coverage"`
	Version         string   `xml:"version,attr"`
	Timestamp       string   `xml:"timestamp,attr"`
	LinesValid      int      `xml:"lines-valid,attr"`
	LinesCovered    int      `xml:"lines-covered,attr"`
	LineRate        float64  `xml:"line-rate,attr"`
	BranchesCovered int      `xml:"branches-covered,attr"`
	BranchesValid   int      `xml:"branches-valid,attr"`
	BranchRate      float64  `xml:"branch-rate,attr"`
	Complexity      int      `xml:"complexity,attr"`
	Sources         struct {
		Source []string `xml:"source"`
	} `xml:"sources"`
	Packages *CoberturaReportPackages `xml:"packages"`
}

type CoberturaReportPackage

type CoberturaReportPackage struct {
	Name       string  `xml:"name,attr"`
	LineRate   float64 `xml:"line-rate,attr"`
	BranchRate float64 `xml:"branch-rate,attr"`
	Complexity int     `xml:"complexity,attr"`
	Classes    struct {
		Class []struct {
			Filename   string  `xml:"filename,attr"`
			Complexity int     `xml:"complexity,attr"`
			LineRate   float64 `xml:"line-rate,attr"`
			BranchRate float64 `xml:"branch-rate,attr"`
			Methods    struct {
				Method []struct {
					Name       string  `xml:"name,attr"`
					Signature  string  `xml:"signature,attr"`
					LineRate   float64 `xml:"line-rate,attr"`
					BranchRate float64 `xml:"branch-rate,attr"`
					Lines      struct {
						Line []struct {
							Number int `xml:"number,attr"`
							Hits   int `xml:"hits,attr"`
						} `xml:"line"`
					} `xml:"lines"`
				}
			} `xml:"methods"`
			Lines struct {
				Line []struct {
					Number int `xml:"number,attr"`
					Hits   int `xml:"hits,attr"`
				} `xml:"line"`
			} `xml:"lines"`
		} `xml:"class"`
	} `xml:"classes"`
}

type CoberturaReportPackages

type CoberturaReportPackages struct {
	Package []CoberturaReportPackage `xml:"package"`
}

type Coverage

type Coverage struct {
	Type    Type          `json:"type"`
	Format  string        `json:"format"`
	Total   int           `json:"total"`
	Covered int           `json:"covered"`
	Files   FileCoverages `json:"files"`
}

func New

func New() *Coverage

func (*Coverage) Compare

func (c *Coverage) Compare(c2 *Coverage) *DiffCoverage

func (*Coverage) DeleteBlockCoverages

func (c *Coverage) DeleteBlockCoverages()

func (*Coverage) Exclude added in v0.57.0

func (c *Coverage) Exclude(exclude []string) error

func (*Coverage) Merge

func (c *Coverage) Merge(c2 *Coverage) error

type DiffCoverage

type DiffCoverage struct {
	A         float64           `json:"a"`
	B         float64           `json:"b"`
	Diff      float64           `json:"diff"`
	CoverageA *Coverage         `json:"-"`
	CoverageB *Coverage         `json:"-"`
	Files     DiffFileCoverages `json:"files"`
}

type DiffFileCoverage

type DiffFileCoverage struct {
	File          string        `json:"file"`
	A             float64       `json:"a"`
	B             float64       `json:"b"`
	Diff          float64       `json:"diff"`
	FileCoverageA *FileCoverage `json:"-"`
	FileCoverageB *FileCoverage `json:"-"`
}

type DiffFileCoverages

type DiffFileCoverages []*DiffFileCoverage

func (DiffFileCoverages) FuzzyFindByFile

func (dc DiffFileCoverages) FuzzyFindByFile(file string) (*DiffFileCoverage, error)

type FileCoverage

type FileCoverage struct {
	Type    Type           `json:"type"`
	File    string         `json:"file"`
	Total   int            `json:"total"`
	Covered int            `json:"covered"`
	Blocks  BlockCoverages `json:"blocks,omitempty"`
	// contains filtered or unexported fields
}

func NewFileCoverage

func NewFileCoverage(file string, coverageType Type) *FileCoverage

func (*FileCoverage) FindBlocksByLine

func (fc *FileCoverage) FindBlocksByLine(n int) BlockCoverages

type FileCoverages

type FileCoverages []*FileCoverage

func (FileCoverages) FindByFile

func (fc FileCoverages) FindByFile(file string) (*FileCoverage, error)

func (FileCoverages) FuzzyFindByFile

func (fc FileCoverages) FuzzyFindByFile(file string) (*FileCoverage, error)

type Gocover

type Gocover struct{}

func NewGocover

func NewGocover() *Gocover

func (*Gocover) Name

func (g *Gocover) Name() string

func (*Gocover) ParseReport

func (g *Gocover) ParseReport(path string) (*Coverage, string, error)

type Jacoco

type Jacoco struct{}

func NewJacoco

func NewJacoco() *Jacoco

func (*Jacoco) Name

func (c *Jacoco) Name() string

func (*Jacoco) ParseReport

func (c *Jacoco) ParseReport(path string) (*Coverage, string, error)

type JacocoReport

type JacocoReport struct {
	XMLName     xml.Name `xml:"report"`
	Text        string   `xml:",chardata"`
	Name        string   `xml:"name,attr"`
	Sessioninfo []struct {
		Text  string `xml:",chardata"`
		ID    string `xml:"id,attr"`
		Start string `xml:"start,attr"`
		Dump  string `xml:"dump,attr"`
	} `xml:"sessioninfo"`
	Package []*JacocoReportPackage `xml:"package"`
	Counter []*JacocoReportCounter `xml:"counter"`
}

type JacocoReportCounter

type JacocoReportCounter struct {
	Text    string `xml:",chardata"`
	Type    string `xml:"type,attr"`
	Missed  int    `xml:"missed,attr"`
	Covered int    `xml:"covered,attr"`
}

type JacocoReportPackage

type JacocoReportPackage struct {
	Text  string `xml:",chardata"`
	Name  string `xml:"name,attr"`
	Class []struct {
		Text           string `xml:",chardata"`
		Name           string `xml:"name,attr"`
		Sourcefilename string `xml:"sourcefilename,attr"`
		Method         []struct {
			Text    string                 `xml:",chardata"`
			Name    string                 `xml:"name,attr"`
			Desc    string                 `xml:"desc,attr"`
			Line    int                    `xml:"line,attr"`
			Counter []*JacocoReportCounter `xml:"counter"`
		} `xml:"method"`
		Counter []*JacocoReportCounter `xml:"counter"`
	} `xml:"class"`
	Sourcefile []struct {
		Text string `xml:",chardata"`
		Name string `xml:"name,attr"`
		Line []struct {
			Text string `xml:",chardata"`
			Nr   int    `xml:"nr,attr"` // line number
			Mi   int    `xml:"mi,attr"` // missed interactions
			Ci   int    `xml:"ci,attr"` // covered interactions
			Mb   int    `xml:"mb,attr"` // missed branches
			Cb   int    `xml:"cb,attr"` // covered branches
		} `xml:"line"`
		Counter []*JacocoReportCounter `xml:"counter"`
	} `xml:"sourcefile"`
	Counter []*JacocoReportCounter `xml:"counter"`
}

type Lcov

type Lcov struct{}

func NewLcov

func NewLcov() *Lcov

func (*Lcov) Name

func (l *Lcov) Name() string

func (*Lcov) ParseReport

func (l *Lcov) ParseReport(path string) (*Coverage, string, error)

type LineCoverage

type LineCoverage struct {
	Line         int
	Count        int
	PosCoverages PosCoverages
}

type LineCoverages

type LineCoverages []*LineCoverage

func (LineCoverages) Covered

func (lc LineCoverages) Covered() int

func (LineCoverages) FindByLine

func (lc LineCoverages) FindByLine(l int) (*LineCoverage, error)

func (LineCoverages) Total

func (lc LineCoverages) Total() int

type PosCoverage

type PosCoverage struct {
	Pos   int
	Count int
}

type PosCoverages

type PosCoverages []*PosCoverage

func (PosCoverages) FindCountByPos

func (pc PosCoverages) FindCountByPos(pos int) (int, error)

type Printer

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

func NewPrinter

func NewPrinter(fc *FileCoverage) *Printer

func (*Printer) Print

func (p *Printer) Print(src io.Reader, dest io.Writer) error

type Processor

type Processor interface {
	Name() string
	ParseReport(path string) (*Coverage, string, error)
}

type Simplecov

type Simplecov struct{}

func NewSimplecov

func NewSimplecov() *Simplecov

func (*Simplecov) Name

func (s *Simplecov) Name() string

func (*Simplecov) ParseReport

func (s *Simplecov) ParseReport(path string) (*Coverage, string, error)

type SimplecovCoverage

type SimplecovCoverage struct {
	Coverage map[string]SimplecovFileCoverage `json:"coverage"`
}

func (*SimplecovCoverage) UnmarshalJSON

func (c *SimplecovCoverage) UnmarshalJSON(data []byte) error

type SimplecovFileCoverage

type SimplecovFileCoverage struct {
	Lines []any `json:"lines"`
}

type SimplecovReport

type SimplecovReport map[string]SimplecovCoverage

type Type

type Type string
const (
	TypeLOC    Type = "loc"
	TypeStmt   Type = "statement"
	TypeMerged Type = "merged"
)

Jump to

Keyboard shortcuts

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