Documentation
¶
Overview ¶
Package analyzer provides functions and types for analyzing code coverage and exclusions in the uncloak application.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBelowThreshold is returned when the new code coverage is below the // configured threshold. ErrBelowThreshold = errors.New("new code coverage below threshold") )
Functions ¶
This section is empty.
Types ¶
type FileReport ¶
type FileReport struct {
Path string
CoveredNewLines []int
CoveredNewLineGroups []LineRange
UncoveredNewLines []int
UncoveredNewLineGroups []LineRange
}
FileReport represents the coverage report for a single file, including covered and uncovered new lines and their respective ranges.
func NewFileReport ¶
func NewFileReport(path string) *FileReport
NewFileReport creates a new FileReport instance for the given file path.
func (*FileReport) GroupCoveredLines ¶
func (fr *FileReport) GroupCoveredLines()
GroupCoveredLines groups the covered new lines in the file into ranges of consecutive lines.
func (*FileReport) GroupUncoveredLines ¶
func (fr *FileReport) GroupUncoveredLines()
GroupUncoveredLines groups the uncovered new lines in the file into ranges of consecutive lines.
func (*FileReport) TotalNewLines ¶
func (fr *FileReport) TotalNewLines() int
TotalNewLines returns the total number of new lines in the file report, which is the sum of covered and uncovered new lines.
type LineRange ¶
LineRange represents a continuous range of lines in a file, with a start and end line number.
type Report ¶
type Report struct {
CoverageThreshold float64
CoverageProfile *gocover.Profile
GitDiffResults *gitdiff.Results
Files []*FileReport
}
Report represents the analysis report for a Go project, including the coverage threshold, coverage profile, git diff results, and file-specific reports.
func NewCodeCoverage ¶
NewCodeCoverage analyzes the Go coverage profile and the git diff file, returning a report of the coverage of new lines in the code. It returns a Report of the analyzed coverage and an error if any occurs during the analysis. If the coverage of new lines is below the threshold specified in the configuration, it returns ErrBelowThreshold as the error.
func NewReport ¶
func NewReport(coverageThreshold float64, coverageProfile *gocover.Profile, gitDiff *gitdiff.Results) *Report
NewReport creates a new Report instance with the provided coverage threshold, coverage profile, and git diff.
func (*Report) CoveragePercent ¶
CoveragePercent calculates and returns the coverage percentage of new lines in the report.
func (*Report) GroupCoveredLines ¶
func (r *Report) GroupCoveredLines()
GroupCoveredLines groups the covered new lines in each file into ranges of consecutive lines.
func (*Report) GroupUncoveredLines ¶
func (r *Report) GroupUncoveredLines()
GroupUncoveredLines groups the uncovered new lines in each file into ranges of consecutive lines.
func (*Report) HasUncoveredLines ¶
HasUncoveredLines checks if there are any uncovered new lines in the report.
func (*Report) TotalCoveredNewLines ¶
TotalCoveredNewLines calculates and returns the total number of covered new lines across all files in the report.
func (*Report) TotalNewLines ¶
TotalNewLines calculates and returns the total number of new lines across all files in the report.