formatters

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Coverage

type Coverage []NullInt

func (*Coverage) AppendNulls

func (c *Coverage) AppendNulls(quantity int) Coverage

func (Coverage) MarshalJSON

func (c Coverage) MarshalJSON() ([]byte, error)

MarshalJSON marshals the coverage into JSON. Since the Code Climate API requires this as a string "[1,2,null]" and not just a straight JSON array we have to do a bunch of work to coerce into that format

func (*Coverage) UnmarshalJSON

func (c *Coverage) UnmarshalJSON(text []byte) error

type Environment

type Environment struct {
	GemVersion      string `json:"gem_version"`
	PackageVersion  string `json:"package_version"`
	PWD             string `json:"pwd"`
	Prefix          string `json:"prefix"`
	RailsRoot       string `json:"rails_root"`
	ReporterVersion string `json:"reporter_version"`
	SimplecovRoot   string `json:"simplecov_root"`
}

type Formatter

type Formatter interface {
	// Search for the both the "standard" paths for the formatter,
	// plus any additional paths, for a file that can be parsed
	// by the formatter.
	Search(...string) (string, error)
	// Format the information for Parse into a standardized "Report".
	// Returns an error if there was a problem formatting the results.
	Format() (Report, error)
}

Formatter needs to be implemented for each new test system

type LineCounts

type LineCounts struct {
	Missed   int `json:"missed"`
	Covered  int `json:"covered"`
	Total    int `json:"total"`
	Strength int `json:"-"`
}

func (LineCounts) CoveredPercent

func (lc LineCounts) CoveredPercent() float64

func (LineCounts) CoveredStrength

func (lc LineCounts) CoveredStrength() float64

type NullInt

type NullInt struct {
	Int   int
	Valid bool // Valid is true if Int is not NULL
}

NullInt adds an implementation for int that supports proper JSON encoding/decoding.

func NewNullInt

func NewNullInt(i int) NullInt

NewNullInt returns a new, properly instantiated Int object.

func (NullInt) Interface

func (ns NullInt) Interface() interface{}

func (NullInt) MarshalJSON

func (ns NullInt) MarshalJSON() ([]byte, error)

MarshalJSON marshals the underlying value to a proper JSON representation.

func (*NullInt) UnmarshalJSON

func (ns *NullInt) UnmarshalJSON(text []byte) error

UnmarshalJSON will unmarshal a JSON value into the propert representation of that value.

func (*NullInt) UnmarshalText

func (ns *NullInt) UnmarshalText(text []byte) error

type Report

type Report struct {
	CIService       ccCIService `json:"ci_service"`
	Environment     Environment `json:"environment"`
	Git             ccGit       `json:"git"`
	CoveredPercent  float64     `json:"covered_percent"`
	CoveredStrength int         `json:"covered_strength"`
	LineCounts      LineCounts  `json:"line_counts"`
	SourceFiles     SourceFiles `json:"source_files"`
	RepoToken       string      `json:"repo_token"`
}

func NewReport

func NewReport() (Report, error)

func (*Report) AddSourceFile

func (rep *Report) AddSourceFile(sf SourceFile) error

func (*Report) Merge

func (a *Report) Merge(reps ...*Report) error

func (Report) Save

func (r Report) Save(w io.Writer) error

type SourceFile

type SourceFile struct {
	BlobID          string     `json:"blob_id"`
	Coverage        Coverage   `json:"coverage"`
	CoveredPercent  float64    `json:"covered_percent"`
	CoveredStrength float64    `json:"covered_strength"`
	LineCounts      LineCounts `json:"line_counts"`
	Name            string     `json:"name"`
}

func NewSourceFile

func NewSourceFile(name string, commit *object.Commit) (SourceFile, error)

func (*SourceFile) CalcLineCounts

func (sf *SourceFile) CalcLineCounts()

func (SourceFile) Merge

func (a SourceFile) Merge(b SourceFile) (SourceFile, error)

type SourceFiles

type SourceFiles map[string]SourceFile

func (SourceFiles) MarshalJSON

func (sf SourceFiles) MarshalJSON() ([]byte, error)

func (SourceFiles) UnmarshalJSON

func (sf SourceFiles) UnmarshalJSON(text []byte) error

Jump to

Keyboard shortcuts

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