Documentation
¶
Index ¶
- func ComputeGoComplexity(src string) map[string]int
- func CoverageForFile(cm CoverageMap, filePath string) float64
- func ParseCoverProfile(profile string) float64
- type CodeMetrics
- type CoverageMap
- type FileCoverage
- type GitStats
- type LintFinding
- type LintResult
- type StructuralMetrics
- type TestResult
- type ToolExecutor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeGoComplexity ¶
ComputeGoComplexity parses Go source and returns cyclomatic complexity per function. Key: function name (or Receiver.Method for methods). Value: complexity.
func CoverageForFile ¶ added in v0.4.0
func CoverageForFile(cm CoverageMap, filePath string) float64
CoverageForFile returns the coverage ratio (0.0–1.0) for a specific file. Returns -1 if the file is not found in the coverage map.
func ParseCoverProfile ¶
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 CoverageMap ¶ added in v0.4.0
type CoverageMap map[string]FileCoverage
CoverageMap maps file paths to their aggregated coverage data.
func ParseCoverProfilePerFunc ¶ added in v0.4.0
func ParseCoverProfilePerFunc(profile string) CoverageMap
ParseCoverProfilePerFunc parses a Go coverage profile and returns per-file coverage data. The profile format is:
mode: set file:startline.col,endline.col numstatements count
type FileCoverage ¶ added in v0.4.0
type FileCoverage struct {
Statements int // Total statements in coverage blocks
Covered int // Statements with count > 0
}
FileCoverage holds aggregated coverage data for a single file.
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 ¶
ParseGitLog parses tab-separated git log output (hash\tauthor\tdate).
func ParseGitLogWithAge ¶
ParseGitLogWithAge parses git log output and computes age from the earliest date.
func (GitStats) ToEvidence ¶
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 AttributeLintToFile ¶ added in v0.4.0
func AttributeLintToFile(findings []LintFinding, filePath string) LintResult
AttributeLintToFile filters lint findings to those belonging to a specific file and returns a LintResult scoped to that file.
func AttributeLintToUnit ¶ added in v0.4.0
func AttributeLintToUnit(findings []LintFinding, filePath string, startLine, endLine int) LintResult
AttributeLintToUnit filters lint findings to those within a specific file and line range [startLine, endLine] inclusive.
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 StructuralMetrics ¶ added in v0.4.0
type StructuralMetrics struct {
HasDocComment bool // Exported func/type has a preceding doc comment
ParamCount int // Number of function parameters (excluding receiver)
ReturnCount int // Number of return values
MaxNestingDepth int // Deepest nesting level within the function body
NakedReturns int // Count of bare return statements in named-return functions
ErrorsIgnored int // Count of blank identifier assignments to error-typed returns
ExportedName bool // Symbol starts with uppercase
ReceiverName string // Receiver type name (empty for standalone functions)
IsConstructor bool // Function name matches New* pattern
}
StructuralMetrics holds AST-derived structural analysis results for a code unit.
func AnalyzeGoFunc ¶ added in v0.4.0
func AnalyzeGoFunc(src string, funcName string) StructuralMetrics
AnalyzeGoFunc parses Go source and analyzes a function or method by name. Returns zero-value StructuralMetrics if the source can't be parsed or symbol not found.
func AnalyzeGoType ¶ added in v0.4.0
func AnalyzeGoType(src string, typeName string) StructuralMetrics
AnalyzeGoType parses Go source and analyzes a type declaration by name.
func (StructuralMetrics) ToEvidence ¶ added in v0.4.0
func (m StructuralMetrics) ToEvidence() domain.Evidence
ToEvidence converts StructuralMetrics 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. After CollectAll(), raw lint findings and coverage profile are retained for per-unit attribution by the certification pipeline.
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) CoverageProfile ¶ added in v0.4.0
func (te *ToolExecutor) CoverageProfile() string
CoverageProfile returns the raw Go coverage profile collected during CollectAll(). Returns empty string if coverage was not collected.
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.
func (*ToolExecutor) LintFindings ¶ added in v0.4.0
func (te *ToolExecutor) LintFindings() []LintFinding
LintFindings returns all lint findings collected during CollectAll(). Returns nil if no lint tools were run or found no issues.