Documentation ¶
Index ¶
- Constants
- func GetPackages(profiles []*Profile) ([]*packages.Package, error)
- func ReportListToJSON(r []*Report) ([]byte, error)
- type Boundary
- type CheckStyleError
- type CheckStyleFile
- type CheckStyleResult
- type Class
- type Coverage
- type Ignore
- type Line
- type Lines
- type Method
- type Package
- type Profile
- type ProfileBlock
- type Report
- type ReportContent
- type ReportLocation
- type ReportLocationLines
- type ReportLocationPositions
- type ReportLocationPositionsData
- type Source
Constants ¶
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" )
const CoberturaDTDDecl = `<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">`
Variables ¶
This section is empty.
Functions ¶
func ReportListToJSON ¶
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 ¶
HitRate returns a float32 from 0.0 to 1.0 representing what fraction of lines have hits
func (Class) NumLinesWithHits ¶
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 ¶
HitRate returns a float32 from 0.0 to 1.0 representing what fraction of lines have hits
func (Coverage) NumLinesWithHits ¶
NumLinesWithHits returns the number of lines with a hit count > 0
type Ignore ¶
type Lines ¶
type Lines []*Line
Lines is a slice of Line pointers, with some convenience methods
func (*Lines) AddOrUpdateLine ¶
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 ¶
HitRate returns a float32 from 0.0 to 1.0 representing what fraction of lines have hits
func (Lines) NumLinesWithHits ¶
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 ¶
HitRate returns a float32 from 0.0 to 1.0 representing what fraction of lines have hits
func (Method) NumLinesWithHits ¶
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 ¶
HitRate returns a float32 from 0.0 to 1.0 representing what fraction of lines have hits
func (Package) NumLinesWithHits ¶
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 ¶
ParseProfiles parses profile data from the given Reader and returns a Profile for each file.
func (*Profile) Boundaries ¶
Boundaries returns a Profile as a set of Boundary objects within the provided src.
type ProfileBlock ¶
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 ¶
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 ReportLocationPositions ¶
type ReportLocationPositions struct { Begin ReportLocationPositionsData `json:"begin"` End ReportLocationPositionsData `json:"end"` }