model

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BugRisk       string = "Bug Risk"
	Clarity              = "Clarity"
	Compatibility        = "Compatibility"
	Complexity           = "Complexity"
	Security             = "Security"
	Style                = "Style"

	SeverityInfo     = "info"
	SeverityMinor    = "minor"
	SeverityMajor    = "major"
	SeverityCritical = "critical"
	SeverityBlocker  = "blocker"

	ReportTypeIssue = "issue"

	ReportEngineEslint = "eslint"
)
View Source
const CoberturaDTDDecl = `<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">`

Variables

This section is empty.

Functions

func GetPackages

func GetPackages(profiles []*Profile) ([]*packages.Package, error)

func ReportListToJSON

func ReportListToJSON(r []*Report) ([]byte, error)

Types

type Boundary

type Boundary struct {
	Offset int     // Location as a byte offset in the source file.
	Start  bool    // Is this the start of a block?
	Count  int     // Event count from the cover profile.
	Norm   float64 // Count normalized to [0..1].
}

Boundary represents the position in a source file of the beginning or end of a block as reported by the coverage profile. In HTML mode, it will correspond to the opening or closing of a <span> tag and will be used to colorize the source

type CheckStyleError

type CheckStyleError struct {
	Column   int    `xml:"column,attr,omitempty"`
	Line     int    `xml:"line,attr"`
	Message  string `xml:"message,attr"`
	Severity string `xml:"severity,attr,omitempty"`
	Source   string `xml:"source,attr,omitempty"`
}

CheckStyleError represents <error line="1" column="10" severity="error" message="msg" source="src" />

type CheckStyleFile

type CheckStyleFile struct {
	Name   string             `xml:"name,attr"`
	Errors []*CheckStyleError `xml:"error"`
}

CheckStyleFile represents <file name="fname"><error ... />...</file>

type CheckStyleResult

type CheckStyleResult struct {
	XMLName xml.Name          `xml:"checkstyle"`
	Version string            `xml:"version,attr"`
	Files   []*CheckStyleFile `xml:"file,omitempty"`
}

CheckStyleResult represents checkstyle XML result. <?xml version="1.0" encoding="utf-8"?><checkstyle version="4.3"><file ...></file>...</checkstyle>

References: http://checkstyle.sourceforge.net/ http://eslint.org/docs/user-guide/formatters/#checkstyle

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      Lines     `xml:"lines>line"`
}

func (Class) HitRate

func (class Class) HitRate() float32

HitRate returns a float32 from 0.0 to 1.0 representing what fraction of lines have hits

func (Class) NumLines

func (class Class) NumLines() (numLines int64)

NumLines returns the number of lines

func (Class) NumLinesWithHits

func (class Class) NumLinesWithHits() (numLinesWithHits int64)

NumLinesWithHits returns the number of lines with a hit count > 0

type Coverage

type Coverage struct {
	XMLName         xml.Name   `xml:"coverage"`
	LineRate        float32    `xml:"line-rate,attr"`
	BranchRate      float32    `xml:"branch-rate,attr"`
	Version         string     `xml:"version,attr"`
	Timestamp       int64      `xml:"timestamp,attr"`
	LinesCovered    int64      `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"`
	Sources         []*Source  `xml:"sources>source"`
	Packages        []*Package `xml:"packages>package"`
}

func (Coverage) HitRate

func (cov Coverage) HitRate() float32

HitRate returns a float32 from 0.0 to 1.0 representing what fraction of lines have hits

func (Coverage) NumLines

func (cov Coverage) NumLines() (numLines int64)

NumLines returns the number of lines

func (Coverage) NumLinesWithHits

func (cov Coverage) NumLinesWithHits() (numLinesWithHits int64)

NumLinesWithHits returns the number of lines with a hit count > 0

func (*Coverage) ParseProfiles

func (cov *Coverage) ParseProfiles(profiles []*Profile, pkgMap map[string]*packages.Package, ignore *Ignore) error

type Ignore

type Ignore struct {
	Dirs           *regexp.Regexp
	Files          *regexp.Regexp
	GeneratedFiles bool
	// contains filtered or unexported fields
}

func (*Ignore) Match

func (i *Ignore) Match(fileName string, data []byte) (ret bool)

type Line

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

type Lines

type Lines []*Line

Lines is a slice of Line pointers, with some convenience methods

func (*Lines) AddOrUpdateLine

func (lines *Lines) AddOrUpdateLine(lineNumber int, hits int64)

AddOrUpdateLine adds a line if it is a different line than the last line recorded. If it's the same line as the last line recorded then we update the hits down if the new hits is less; otherwise just leave it as-is

func (Lines) HitRate

func (lines Lines) HitRate() (hitRate float32)

HitRate returns a float32 from 0.0 to 1.0 representing what fraction of lines have hits

func (Lines) NumLines

func (lines Lines) NumLines() int64

NumLines returns the number of lines

func (Lines) NumLinesWithHits

func (lines Lines) NumLinesWithHits() (numLinesWithHits int64)

NumLinesWithHits returns the number of lines with a hit count > 0

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      Lines   `xml:"lines>line"`
}

func (Method) HitRate

func (method Method) HitRate() float32

HitRate returns a float32 from 0.0 to 1.0 representing what fraction of lines have hits

func (Method) NumLines

func (method Method) NumLines() int64

NumLines returns the number of lines

func (Method) NumLinesWithHits

func (method Method) NumLinesWithHits() int64

NumLinesWithHits returns the number of lines with a hit count > 0

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"`
}

func (Package) HitRate

func (pkg Package) HitRate() float32

HitRate returns a float32 from 0.0 to 1.0 representing what fraction of lines have hits

func (Package) NumLines

func (pkg Package) NumLines() (numLines int64)

NumLines returns the number of lines

func (Package) NumLinesWithHits

func (pkg Package) NumLinesWithHits() (numLinesWithHits int64)

NumLinesWithHits returns the number of lines with a hit count > 0

type Profile

type Profile struct {
	FileName string
	Mode     string
	Blocks   []ProfileBlock
}

Profile represents the profiling data for a specific file.

func ParseProfiles

func ParseProfiles(in io.Reader, ignore *Ignore) ([]*Profile, error)

ParseProfiles parses profile data from the given Reader and returns a Profile for each file.

func (*Profile) Boundaries

func (p *Profile) Boundaries(src []byte) []Boundary

Boundaries returns a Profile as a set of Boundary objects within the provided src.

type ProfileBlock

type ProfileBlock struct {
	StartLine, StartCol int
	EndLine, EndCol     int
	NumStmt, Count      int
}

ProfileBlock represents a single block of profiling data.

type Report

type Report struct {
	EngineName        string         `json:"engine_name"`
	Fingerprint       string         `json:"fingerprint,omitempty"`
	Categories        []string       `json:"categories,omitempty"`
	CheckName         string         `json:"check_name"`
	Content           ReportContent  `json:"content,omitempty"`
	Description       string         `json:"description"`
	Location          ReportLocation `json:"location,omitempty"`
	OtherLocations    []interface{}  `json:"other_locations,omitempty"`
	RemediationPoints int            `json:"remediation_points,omitempty"`
	Severity          string         `json:"severity,omitempty"`
	Type              string         `json:"type"`
}

func NewReportFromCheckstyle

func NewReportFromCheckstyle(checkstyleReport *CheckStyleError, reportType string, reportEngine string, fileName string) *Report

func (*Report) ComputeFingerprint

func (r *Report) ComputeFingerprint()

func (*Report) SetCategories

func (r *Report) SetCategories()

func (*Report) SetCheckName

func (r *Report) SetCheckName()

func (*Report) SetDefaults

func (r *Report) SetDefaults()

func (*Report) SetSeverity

func (r *Report) SetSeverity(severity string)

func (*Report) ToJSON

func (r *Report) ToJSON() ([]byte, error)

type ReportContent

type ReportContent struct {
	Body string `json:"body"`
}

type ReportLocation

type ReportLocation struct {
	Path string `json:"path"`
	//Lines     ReportLocationLines     `json:"lines,omitempty"`
	Positions ReportLocationPositions `json:"positions,omitempty"`
}

type ReportLocationLines

type ReportLocationLines struct {
	Begin int `json:"begin"`
	End   int `json:"end"`
}

type ReportLocationPositions

type ReportLocationPositions struct {
	Begin ReportLocationPositionsData `json:"begin"`
	End   ReportLocationPositionsData `json:"end"`
}

type ReportLocationPositionsData

type ReportLocationPositionsData struct {
	Line   int `json:"line"`
	Column int `json:"column"`
}

type Source

type Source struct {
	Path string `xml:",chardata"`
}

func AppendIfUnique

func AppendIfUnique(sources []*Source, dir string) []*Source

Jump to

Keyboard shortcuts

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