gocovsta

package
v0.0.0-...-18d1de7 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package gocovsta implements the parsing and conversion logic for transforming Cobertura XML coverage reports into JSON output, for consumption by the Bitbucket Server code coverage plugin API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Class

type Class struct {
	Name       string   `xml:"name,attr"`
	Filename   string   `xml:"filename,attr"`
	LineRate   float32  `xml:"line-rate,attr"`
	BranchRate float32  `xml:"branch-rate,attr"`
	Complexity float32  `xml:"complexity,attr"`
	Methods    []Method `xml:"methods>method"`
	Lines      []Line   `xml:"lines>line"`
	LineCount  int64    `xml:"line-count,attr"`
	LineHits   int64    `xml:"line-hits,attr"`
}

Class input data.

type Coverage

type Coverage struct {
	XMLName         xml.Name  `xml:"coverage"`
	LineRate        float32   `xml:"line-rate,attr"`
	BranchRate      float32   `xml:"branch-rate,attr"`
	LinesCovered    float32   `xml:"lines-covered,attr"`
	LinesValid      int64     `xml:"lines-valid,attr"`
	BranchesCovered int64     `xml:"branches-covered,attr"`
	BranchesValid   int64     `xml:"branches-valid,attr"`
	Complexity      float32   `xml:"complexity,attr"`
	Version         string    `xml:"version,attr"`
	Timestamp       int64     `xml:"timestamp,attr"`
	Packages        []Package `xml:"packages>package"`
	Sources         []string  `xml:"sources>source"`
}

Coverage input data.

func ParseInput

func ParseInput(r io.Reader) (*Coverage, error)

ParseInput unmarshals the input XML to a Coverage type.

type File

type File struct {
	Path     string `json:"path"`
	Coverage string `json:"coverage"`
	// contains filtered or unexported fields
}

File JSON type.

func (File) Hits

func (f File) Hits() string

Hits returns hits as a comma-separated string.

func (File) Misses

func (f File) Misses() string

Misses returns misses as a comma-separated string.

type Line

type Line struct {
	Number int   `xml:"number,attr"`
	Hits   int64 `xml:"hits,attr"`
}

Line input data.

type Method

type Method struct {
	Name       string  `xml:"name,attr"`
	Signature  string  `xml:"signature,attr"`
	LineRate   float32 `xml:"line-rate,attr"`
	BranchRate float32 `xml:"branch-rate,attr"`
	Complexity float32 `xml:"complexity,attr"`
	Lines      []Line  `xml:"lines>line"`
	LineCount  int64   `xml:"line-count,attr"`
	LineHits   int64   `xml:"line-hits,attr"`
}

Method input data.

type Output

type Output struct {
	Files []File `json:"files"`
}

Output JSON type.

func ParseCoverage

func ParseCoverage(c *Coverage) *Output

ParseCoverage parses the input XML data and generates the Output for marshalling to JSON.

func (*Output) JSON

func (o *Output) JSON() (string, error)

JSON returns the JSON representation of the coverage output.

type Package

type Package struct {
	Name       string  `xml:"name,attr"`
	LineRate   float32 `xml:"line-rate,attr"`
	BranchRate float32 `xml:"branch-rate,attr"`
	Complexity float32 `xml:"complexity,attr"`
	Classes    []Class `xml:"classes>class"`
	LineCount  int64   `xml:"line-count,attr"`
	LineHits   int64   `xml:"line-hits,attr"`
}

Package input data.

Jump to

Keyboard shortcuts

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