evidence

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package evidence handles evidence collection from various sources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeGoComplexity

func ComputeGoComplexity(src string) map[string]int

ComputeGoComplexity parses Go source and returns cyclomatic complexity per function. Key: function name (or Receiver.Method for methods). Value: complexity.

func ParseCoverProfile

func ParseCoverProfile(profile string) float64

ParseCoverProfile parses a Go coverage profile and returns coverage as 0.0-1.0.

Types

type CodeMetrics

type CodeMetrics struct {
	TotalLines   int `json:"total_lines"`
	BlankLines   int `json:"blank_lines"`
	CommentLines int `json:"comment_lines"`
	CodeLines    int `json:"code_lines"`
	TodoCount    int `json:"todo_count"`
	Complexity   int `json:"complexity"`
}

CodeMetrics holds basic code metrics for a file or symbol.

func ComputeMetrics

func ComputeMetrics(src string) CodeMetrics

ComputeMetrics computes basic code metrics from source text.

func ComputeSymbolMetrics

func ComputeSymbolMetrics(src, symbol string) CodeMetrics

ComputeSymbolMetrics computes metrics for a specific symbol within Go source. If the symbol isn't found, falls back to file-level metrics.

func (CodeMetrics) ToEvidence

func (m CodeMetrics) ToEvidence() domain.Evidence

ToEvidence converts CodeMetrics to a domain.Evidence.

type Collector

type Collector interface {
	// Collect gathers evidence for the given unit in the given repo root.
	Collect(root string, unit domain.Unit) (domain.Evidence, error)

	// Kind returns the kind of evidence this collector produces.
	Kind() domain.EvidenceKind
}

Collector gathers evidence for a code unit.

type GitStats

type GitStats struct {
	CommitCount int `json:"commit_count"`
	AuthorCount int `json:"author_count"`
	AgeDays     int `json:"age_days"`
}

GitStats holds parsed git history data for a file.

func ParseGitLog

func ParseGitLog(output string) GitStats

ParseGitLog parses tab-separated git log output (hash\tauthor\tdate).

func ParseGitLogWithAge

func ParseGitLogWithAge(output string, earliestDate string) GitStats

ParseGitLogWithAge parses git log output and computes age from the earliest date.

func (GitStats) ChurnRate

func (s GitStats) ChurnRate() float64

ChurnRate returns commits per day. Returns 0 if age is zero.

func (GitStats) ToEvidence

func (s GitStats) ToEvidence() domain.Evidence

ToEvidence converts GitStats to a domain.Evidence.

type LintFinding

type LintFinding struct {
	File     string `json:"file"`
	Line     int    `json:"line"`
	Message  string `json:"message"`
	Severity string `json:"severity"`
	Rule     string `json:"rule,omitempty"`
}

LintFinding represents a single lint finding.

type LintResult

type LintResult struct {
	Tool       string        `json:"tool"`
	ErrorCount int           `json:"error_count"`
	WarnCount  int           `json:"warn_count"`
	Findings   []LintFinding `json:"findings,omitempty"`
}

LintResult holds aggregated lint results.

func ParseGoVet

func ParseGoVet(stderr string, exitCode int) LintResult

ParseGoVet parses go vet stderr output into a LintResult.

func ParseGolangciLintJSON

func ParseGolangciLintJSON(output string) LintResult

ParseGolangciLintJSON parses golangci-lint JSON output into a LintResult.

func (LintResult) ToEvidence

func (r LintResult) ToEvidence() domain.Evidence

ToEvidence converts LintResult to a domain.Evidence.

type TestResult

type TestResult struct {
	Tool        string  `json:"tool"`
	TotalCount  int     `json:"total_count"`
	PassedCount int     `json:"passed_count"`
	FailedCount int     `json:"failed_count"`
	SkipCount   int     `json:"skip_count"`
	Coverage    float64 `json:"coverage"` // 0.0–1.0
}

TestResult holds aggregated test execution results.

func ParseGoTestJSON

func ParseGoTestJSON(output string) TestResult

ParseGoTestJSON parses `go test -json` output into a TestResult.

func (TestResult) ToEvidence

func (r TestResult) ToEvidence() domain.Evidence

ToEvidence converts TestResult to a domain.Evidence.

type ToolExecutor

type ToolExecutor struct {
	// contains filtered or unexported fields
}

ToolExecutor runs external tools and collects evidence.

func NewToolExecutor

func NewToolExecutor(root string) *ToolExecutor

NewToolExecutor creates a tool executor rooted at the given directory.

func (*ToolExecutor) CollectAll

func (te *ToolExecutor) CollectAll() []domain.Evidence

CollectAll runs all available tool runners and returns collected evidence.

func (*ToolExecutor) HasGoMod

func (te *ToolExecutor) HasGoMod() bool

HasGoMod returns true if the root directory contains a go.mod file.

func (*ToolExecutor) HasPackageJSON

func (te *ToolExecutor) HasPackageJSON() bool

HasPackageJSON returns true if the root has a package.json.

Jump to

Keyboard shortcuts

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