Documentation
¶
Overview ¶
Package analysis provides code ownership and bus-factor analysis tools.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RepositoryExists ¶
RepositoryExists checks if a valid git repository exists at the given path.
func RiskLevelScore ¶
RiskLevelScore returns a numeric score (0-100) for the risk level.
Types ¶
type BusFactorResult ¶
type BusFactorResult struct {
ID int64 `json:"id"`
Component string `json:"component"`
Timestamp time.Time `json:"timestamp"`
Metrics *OwnershipMetrics `json:"metrics"`
Contributors []CommitAuthor `json:"contributors"`
RiskLevel string `json:"risk_level"`
ReportPath string `json:"report_path,omitempty"`
}
BusFactorResult represents a stored bus-factor analysis result.
func LoadAll ¶
LoadAll loads all bus-factor results for a component, optionally filtered by date range.
func LoadLatest ¶
func LoadLatest(db *sql.DB, component string) (*BusFactorResult, error)
LoadLatest loads the most recent bus-factor result for a component.
type CommitAuthor ¶
CommitAuthor represents a commit author's contribution.
type GitParser ¶
type GitParser struct {
// contains filtered or unexported fields
}
GitParser extracts commit history from a git repository.
func NewGitParser ¶
NewGitParser creates a new git parser for the given repository path.
func (*GitParser) ParseAuthors ¶
func (gp *GitParser) ParseAuthors(opts ParseOptions) ([]CommitAuthor, error)
ParseAuthors extracts authors and their commit counts from git history. Supports filtering by date range and file patterns.
type OwnershipMetrics ¶
type OwnershipMetrics struct {
// HerfindahlIndex measures concentration (0-1 scale, 1 = max concentration)
HerfindahlIndex float64 `json:"herfindahl_index"`
// GiniCoefficient measures inequality (0 = equal, 1 = max inequality)
GiniCoefficient float64 `json:"gini_coefficient"`
// Top 1, 3, 5 ownership percentages
Top1Percent float64 `json:"top_1_percent"`
Top3Percent float64 `json:"top_3_percent"`
Top5Percent float64 `json:"top_5_percent"`
// Risk level assessment
RiskLevel string `json:"risk_level"` // low, medium, high, critical
// Number of contributors
TotalContributors int `json:"total_contributors"`
// Minimum contributors needed to reach 50% of commits
BusFactor int `json:"bus_factor"`
}
OwnershipMetrics contains calculated bus-factor metrics.
func CalculateMetrics ¶
func CalculateMetrics(authors []CommitAuthor) *OwnershipMetrics
CalculateMetrics computes ownership concentration metrics from authors.
func (*OwnershipMetrics) String ¶
func (om *OwnershipMetrics) String() string
String returns a human-readable summary of metrics.
type ParseOptions ¶
ParseOptions defines filtering options for git history parsing.
type Report ¶
type Report struct {
Timestamp time.Time `json:"timestamp"`
Component string `json:"component"` // "overall", "dir/path", etc
Metrics *OwnershipMetrics `json:"metrics"`
Contributors []CommitAuthor `json:"contributors"`
Recommendations []string `json:"recommendations"`
ReportedAt string `json:"reported_at"`
}
Report represents a bus-factor analysis report for a codebase or component.
type ReportGenerator ¶
type ReportGenerator struct{}
ReportGenerator creates formatted reports from analysis results.
func NewReportGenerator ¶
func NewReportGenerator() *ReportGenerator
NewReportGenerator creates a new report generator.
func (*ReportGenerator) Generate ¶
func (rg *ReportGenerator) Generate(component string, authors []CommitAuthor, metrics *OwnershipMetrics) *Report
Generate creates a report from authors and metrics.
func (*ReportGenerator) RenderMarkdown ¶
func (rg *ReportGenerator) RenderMarkdown(report *Report) string
RenderMarkdown generates a markdown representation of the report.