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) printer
- type Color
- type GoModParser
- type GoSrcFile
- type ModuleAnalyzer
- type ModuleParser
- type Parser
Constants ¶
This section is empty.
Variables ¶
View Source
var AnalyzeModule = func(rootDir string) (analyzedFiles []gosrc.AnalyzedFile, err error) { srcFiles, err := discoverSrcFiles(rootDir) if err != nil { return nil, err } for _, goSrcFile := range srcFiles { functions, err := ExploreFunctions(goSrcFile.Path) if err != nil { return nil, errors.New(fmt.Errorf("failed opening '%s': %w", goSrcFile, err)) } analyzedFiles = append(analyzedFiles, gosrc.AnalyzedFile{ FileName: goSrcFile.Name, FilePath: goSrcFile.Path, Functions: functions, }) } return analyzedFiles, nil }
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(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 := AnalyzeModule(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)
func NewPrinter ¶
Types ¶
type Color ¶
type Color string
const ( ColorRed Color = "\033[31m" ColorGreen Color = "\033[32m" ColorYellow Color = "\033[33m" ColorBlue Color = "\033[34m" ColorPurple Color = "\033[35m" ColorCyan Color = "\033[36m" ColorWhite Color = "\033[37m" )
ASCII escape codes for colors, see: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
type ModuleAnalyzer ¶
type ModuleAnalyzer func(string) ([]gosrc.AnalyzedFile, error)
type ModuleParser ¶
type ModuleParser func(string, ModuleAnalyzer) (module.Module, error)
Click to show internal directories.
Click to hide internal directories.