Documentation ¶
Index ¶
- Variables
- func BuildStatementStatistic(module module.Module, parsedCoverage coverage.CoverageLines) *statistic.ModuleStatistic
- func Evaluate(moduleStatistic statistic.ModuleStatistic, cfg dto.CoverageConfig) (errs []evaluation.CoverageError, err error)
- func ExploreFunctions(filePath string) (functions []gosrc.Function, err error)
- func GroupCoverageByDirectory(moduleName string, coverageLines coverage.CoverageLines) (group coverage.GroupedCoverage)
- func NewPrinter(w io.Writer, fmt dto.Formatter) printer
- type GoModParser
- type GoSrcFile
- type ModuleAnalyzer
- type ModuleParser
- type Parser
Constants ¶
This section is empty.
Variables ¶
View Source
var ParseFile = func(file io.Reader) coverage.CoverageLines { lineMatcher := coverage.NewLineMatcher() parsedLines := coverage.CoverageLines{} scanner := bufio.NewScanner(file) scanner.Split(bufio.ScanLines) for scanner.Scan() { line := scanner.Text() if strings.HasPrefix(line, "mode:") { continue } parsedLine, err := lineMatcher.Apply(line) if err == nil { parsedLines = append(parsedLines, parsedLine) } } return parsedLines }
View Source
var ParseGoMod = func(f io.Reader) (module.GoMod, error) { goModContent, err := io.ReadAll(f) if err != nil { return module.GoMod{}, errors.New(fmt.Errorf("failed reading go.mod: %w", err)) } regex := regexp.MustCompile(goModRegex) matches := regex.FindStringSubmatch(string(goModContent)) if len(matches) != 3 { return module.GoMod{}, errors.New("couldn't detect go.mod components") } return module.GoMod{ ModuleName: matches[1], GoVersion: matches[2], }, nil }
View Source
var ParseModule = func(rootDir string, srcAnalyzer ModuleAnalyzer) (module.Module, error) { gomodFile, err := os.Open(filepath.Clean(path.Join(rootDir, "go.mod"))) if err != nil { return module.Module{}, errors.New(fmt.Errorf("failed opening go.mod: %w", err)) } defer gomodFile.Close() gomod, err := ParseGoMod(gomodFile) if err != nil { return module.Module{}, err } analyzedFiles, err := srcAnalyzer(rootDir) if err != nil { return module.Module{}, err } return module.Module{ GoMod: gomod, Files: analyzedFiles, }, nil }
Functions ¶
func BuildStatementStatistic ¶
func BuildStatementStatistic(module module.Module, parsedCoverage coverage.CoverageLines) *statistic.ModuleStatistic
func Evaluate ¶
func Evaluate(moduleStatistic statistic.ModuleStatistic, cfg dto.CoverageConfig) (errs []evaluation.CoverageError, err error)
func ExploreFunctions ¶
func GroupCoverageByDirectory ¶
func GroupCoverageByDirectory(moduleName string, coverageLines coverage.CoverageLines) (group coverage.GroupedCoverage)
Types ¶
type ModuleAnalyzer ¶
type ModuleAnalyzer func(string) ([]gosrc.AnalyzedFile, error)
func NewModuleAnalyzer ¶
func NewModuleAnalyzer(excludes []string) ModuleAnalyzer
type ModuleParser ¶
type ModuleParser func(string, ModuleAnalyzer) (module.Module, error)
Click to show internal directories.
Click to hide internal directories.