Documentation
¶
Overview ¶
Package devs provides devs functionality.
Index ¶
- Constants
- Variables
- func AggregateCommitsToTicks(commitDevData map[string]*CommitDevData, commitsByTick map[int][]gitlib.Hash) map[int]map[int]*DevTick
- func GenerateChart(report analyze.Report) (components.Charter, error)
- func GenerateDashboard(report analyze.Report, writer io.Writer) error
- func GenerateSections(report analyze.Report) ([]plotpage.Section, error)
- func RegisterDevPlotSections()
- type ActivityData
- type ActivityMetric
- type AggregateData
- type AggregateInput
- type AggregateMetric
- type Analyzer
- func (a *Analyzer) ApplySnapshot(snap analyze.PlumbingSnapshot)
- func (a *Analyzer) Configure(facts map[string]any) error
- func (a *Analyzer) Consume(_ context.Context, ac *analyze.Context) (analyze.TC, error)
- func (a *Analyzer) ExtractCommitTimeSeries(report analyze.Report) map[string]any
- func (a *Analyzer) Fork(n int) []analyze.HistoryAnalyzer
- func (a *Analyzer) GenerateChart(report analyze.Report) (components.Charter, error)
- func (a *Analyzer) GenerateDashboardForAnalyzer(report analyze.Report, writer io.Writer) error
- func (a *Analyzer) GenerateSections(report analyze.Report) ([]plotpage.Section, error)
- func (a *Analyzer) Initialize(_ *gitlib.Repository) error
- func (a *Analyzer) Merge(_ []analyze.HistoryAnalyzer)
- func (a *Analyzer) NewAggregator(opts analyze.AggregatorOptions) analyze.Aggregator
- func (a *Analyzer) ReleaseSnapshot(_ analyze.PlumbingSnapshot)
- func (a *Analyzer) ReportFromTICKs(ctx context.Context, ticks []analyze.TICK) (analyze.Report, error)
- func (a *Analyzer) Serialize(result analyze.Report, format string, writer io.Writer) error
- func (a *Analyzer) SerializeTICKs(ticks []analyze.TICK, format string, writer io.Writer) error
- func (a *Analyzer) SnapshotPlumbing() analyze.PlumbingSnapshot
- type BusFactorData
- type BusFactorInput
- type BusFactorMetric
- type ChurnData
- type ChurnMetric
- type CommitDevData
- type ComputedMetrics
- type DashboardData
- type DevTick
- type DeveloperData
- type DevelopersMetric
- type IdentityAuditEntry
- type LanguageData
- type LanguagesMetric
- type TickData
- type TickDevData
Constants ¶
const ( ConfigDevsConsiderEmptyCommits = "Devs.ConsiderEmptyCommits" ConfigDevsAnonymize = "Devs.Anonymize" )
Configuration option keys for the devs analyzer.
const ( ThresholdCritical = 90.0 ThresholdHigh = 80.0 ThresholdMedium = 60.0 )
Risk thresholds.
const ( RiskCritical = "CRITICAL" RiskHigh = "HIGH" RiskMedium = "MEDIUM" RiskLow = "LOW" )
Risk level constants.
const ActiveThresholdRatio = 0.7
ActiveThresholdRatio defines what portion of analysis period counts as "recent". Used as fallback when TickSize is not available.
const DefaultActiveDays = 90
DefaultActiveDays is the time-based threshold for considering a developer "active". Developers with commits in the last 90 days are counted as active.
Variables ¶
var (
ErrInvalidPeopleDict = errors.New("devs: invalid ReversedPeopleDict in report")
)
Error definitions for the devs analyzer.
Functions ¶
func AggregateCommitsToTicks ¶
func AggregateCommitsToTicks( commitDevData map[string]*CommitDevData, commitsByTick map[int][]gitlib.Hash, ) map[int]map[int]*DevTick
AggregateCommitsToTicks builds per-tick per-developer data from per-commit data grouped by the commits_by_tick mapping.
func GenerateChart ¶
func GenerateChart(report analyze.Report) (components.Charter, error)
GenerateChart creates a stacked bar chart showing developer activity over time.
func GenerateDashboard ¶
GenerateDashboard creates the developer analytics dashboard HTML.
func GenerateSections ¶
GenerateSections returns the dashboard sections without rendering.
func RegisterDevPlotSections ¶
func RegisterDevPlotSections()
RegisterDevPlotSections registers the plot section renderer for the devs analyzer.
Types ¶
type ActivityData ¶
type ActivityData struct {
Tick int `json:"tick" yaml:"tick"`
ByDeveloper map[int]int `json:"by_developer" yaml:"by_developer"`
TotalCommits int `json:"total_commits" yaml:"total_commits"`
}
ActivityData contains time-series activity for a single tick.
type ActivityMetric ¶
type ActivityMetric struct {
metrics.MetricMeta
}
ActivityMetric computes time-series commit activity.
func NewActivityMetric ¶
func NewActivityMetric() *ActivityMetric
NewActivityMetric creates the activity metric.
func (*ActivityMetric) Compute ¶
func (m *ActivityMetric) Compute(input *TickData) []ActivityData
Compute calculates activity time series from tick data.
type AggregateData ¶
type AggregateData struct {
TotalCommits int `json:"total_commits" yaml:"total_commits"`
TotalLinesAdded int `json:"total_lines_added" yaml:"total_lines_added"`
TotalLinesRemoved int `json:"total_lines_removed" yaml:"total_lines_removed"`
TotalDevelopers int `json:"total_developers" yaml:"total_developers"`
ActiveDevelopers int `json:"active_developers" yaml:"active_developers"`
AnalysisPeriodTicks int `json:"analysis_period_ticks" yaml:"analysis_period_ticks"`
ProjectBusFactor int `json:"project_bus_factor" yaml:"project_bus_factor"`
TotalLanguages int `json:"total_languages" yaml:"total_languages"`
}
AggregateData contains summary statistics.
type AggregateInput ¶
type AggregateInput struct {
Developers []DeveloperData
Languages []LanguageData
Ticks map[int]map[int]*DevTick
TickSize time.Duration
}
AggregateInput is the input for aggregate computation.
type AggregateMetric ¶
type AggregateMetric struct {
metrics.MetricMeta
}
AggregateMetric computes summary statistics.
func NewAggregateMetric ¶
func NewAggregateMetric() *AggregateMetric
NewAggregateMetric creates the aggregate metric.
func (*AggregateMetric) Compute ¶
func (m *AggregateMetric) Compute(input AggregateInput) AggregateData
Compute calculates aggregate statistics.
type Analyzer ¶
type Analyzer struct {
*analyze.BaseHistoryAnalyzer[*ComputedMetrics]
Identity *plumbing.IdentityDetector
TreeDiff *plumbing.TreeDiffAnalyzer
Ticks *plumbing.TicksSinceStart
Languages *plumbing.LanguagesDetectionAnalyzer
LineStats *plumbing.LinesStatsCalculator
ConsiderEmptyCommits bool
Anonymize bool
// contains filtered or unexported fields
}
Analyzer calculates per-developer line statistics across commit history.
func (*Analyzer) ApplySnapshot ¶
func (a *Analyzer) ApplySnapshot(snap analyze.PlumbingSnapshot)
ApplySnapshot restores plumbing state from a snapshot.
func (*Analyzer) Consume ¶
Consume processes a single commit and returns a TC with per-commit dev stats.
func (*Analyzer) ExtractCommitTimeSeries ¶
ExtractCommitTimeSeries extracts per-commit dev stats from a finalized report.
func (*Analyzer) Fork ¶
func (a *Analyzer) Fork(n int) []analyze.HistoryAnalyzer
Fork creates independent copies of the analyzer for parallel processing.
func (*Analyzer) GenerateChart ¶
GenerateChart creates a chart for the history analyzer.
func (*Analyzer) GenerateDashboardForAnalyzer ¶
GenerateDashboardForAnalyzer creates the full dashboard for this analyzer.
func (*Analyzer) GenerateSections ¶
GenerateSections returns the dashboard sections for combined reports.
func (*Analyzer) Initialize ¶
func (a *Analyzer) Initialize(_ *gitlib.Repository) error
Initialize prepares the analyzer for processing commits.
func (*Analyzer) NewAggregator ¶
func (a *Analyzer) NewAggregator(opts analyze.AggregatorOptions) analyze.Aggregator
NewAggregator creates an aggregator for this analyzer.
func (*Analyzer) ReleaseSnapshot ¶
func (a *Analyzer) ReleaseSnapshot(_ analyze.PlumbingSnapshot)
ReleaseSnapshot is a no-op for devs.
func (*Analyzer) ReportFromTICKs ¶
func (a *Analyzer) ReportFromTICKs(ctx context.Context, ticks []analyze.TICK) (analyze.Report, error)
ReportFromTICKs converts aggregated TICKs into a Report.
func (*Analyzer) SerializeTICKs ¶
SerializeTICKs converts aggregated TICKs into the final report and serializes it.
func (*Analyzer) SnapshotPlumbing ¶
func (a *Analyzer) SnapshotPlumbing() analyze.PlumbingSnapshot
SnapshotPlumbing captures the current plumbing state.
type BusFactorData ¶
type BusFactorData struct {
Language string `json:"language" yaml:"language"`
BusFactor int `json:"bus_factor" yaml:"bus_factor"`
TotalContributors int `json:"total_contributors" yaml:"total_contributors"`
PrimaryDevID int `json:"primary_dev_id" yaml:"primary_dev_id"`
PrimaryDevName string `json:"primary_dev_name" yaml:"primary_dev_name"`
PrimaryPct float64 `json:"primary_percentage" yaml:"primary_percentage"`
SecondaryDevID int `json:"secondary_dev_id,omitempty" yaml:"secondary_dev_id,omitempty"`
SecondaryDevName string `json:"secondary_dev_name,omitempty" yaml:"secondary_dev_name,omitempty"`
SecondaryPct float64 `json:"secondary_percentage,omitempty" yaml:"secondary_percentage,omitempty"`
RiskLevel string `json:"risk_level" yaml:"risk_level"`
}
BusFactorData contains knowledge concentration data for a language. BusFactor follows the CHAOSS Contributor Absence Factor methodology: the smallest number of contributors responsible for 50% of total contributions.
type BusFactorInput ¶
type BusFactorInput struct {
Languages []LanguageData
Names []string
}
BusFactorInput is the input for bus factor computation.
type BusFactorMetric ¶
type BusFactorMetric struct {
metrics.MetricMeta
}
BusFactorMetric computes knowledge concentration risk per language.
func NewBusFactorMetric ¶
func NewBusFactorMetric() *BusFactorMetric
NewBusFactorMetric creates the bus factor metric.
func (*BusFactorMetric) Compute ¶
func (m *BusFactorMetric) Compute(input BusFactorInput) []BusFactorData
Compute calculates bus factor risk from language data. Contributors map values represent total contribution (Added+Removed).
type ChurnData ¶
type ChurnData struct {
Tick int `json:"tick" yaml:"tick"`
Added int `json:"lines_added" yaml:"lines_added"`
Removed int `json:"lines_removed" yaml:"lines_removed"`
Net int `json:"net_change" yaml:"net_change"`
}
ChurnData contains code churn for a single tick.
type ChurnMetric ¶
type ChurnMetric struct {
metrics.MetricMeta
}
ChurnMetric computes time-series code churn.
func (*ChurnMetric) Compute ¶
func (m *ChurnMetric) Compute(input *TickData) []ChurnData
Compute calculates churn time series from tick data.
type CommitDevData ¶
type CommitDevData struct {
Commits int `json:"commits"`
Added int `json:"lines_added"`
Removed int `json:"lines_removed"`
Changed int `json:"lines_changed"`
AuthorID int `json:"author_id"`
Languages map[string]pkgplumbing.LineStats `json:"languages,omitempty"`
}
CommitDevData holds aggregate dev stats for a single commit.
type ComputedMetrics ¶
type ComputedMetrics struct {
Ticks map[int]map[int]*DevTick `json:"-" yaml:"-"`
TickSize time.Duration `json:"-" yaml:"-"`
Aggregate AggregateData `json:"aggregate" yaml:"aggregate"`
Developers []DeveloperData `json:"developers" yaml:"developers"`
Languages []LanguageData `json:"languages" yaml:"languages"`
BusFactor []BusFactorData `json:"busfactor" yaml:"busfactor"`
Activity []ActivityData `json:"activity" yaml:"activity"`
Churn []ChurnData `json:"churn" yaml:"churn"`
}
ComputedMetrics holds all computed metric results for the devs analyzer. This is populated by running each metric's Compute method.
func ComputeAllMetrics ¶
func ComputeAllMetrics(report analyze.Report) (*ComputedMetrics, error)
ComputeAllMetrics runs all devs metrics and returns the results.
func (*ComputedMetrics) AnalyzerName ¶
func (m *ComputedMetrics) AnalyzerName() string
AnalyzerName returns the analyzer identifier.
func (*ComputedMetrics) ToJSON ¶
func (m *ComputedMetrics) ToJSON() any
ToJSON returns the metrics in JSON-serializable format.
func (*ComputedMetrics) ToYAML ¶
func (m *ComputedMetrics) ToYAML() any
ToYAML returns the metrics in YAML-serializable format.
type DashboardData ¶
type DashboardData struct {
Metrics *ComputedMetrics
TopLanguages []string // Top N language names for radar chart.
}
DashboardData wraps ComputedMetrics with rendering-specific data.
type DevTick ¶
type DevTick struct {
pkgplumbing.LineStats
Languages map[string]pkgplumbing.LineStats
Commits int
}
DevTick is the statistics for a development tick and a particular developer.
type DeveloperData ¶
type DeveloperData struct {
ID int `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Commits int `json:"commits" yaml:"commits"`
Added int `json:"lines_added" yaml:"lines_added"`
Removed int `json:"lines_removed" yaml:"lines_removed"`
Changed int `json:"lines_changed" yaml:"lines_changed"`
NetLines int `json:"net_lines" yaml:"net_lines"`
Languages map[string]pkgplumbing.LineStats `json:"languages" yaml:"languages"`
FirstTick int `json:"first_tick" yaml:"first_tick"`
LastTick int `json:"last_tick" yaml:"last_tick"`
ActiveTicks int `json:"active_ticks" yaml:"active_ticks"`
}
DeveloperData contains computed data for a single developer.
type DevelopersMetric ¶
type DevelopersMetric struct {
metrics.MetricMeta
}
DevelopersMetric computes per-developer statistics.
func NewDevelopersMetric ¶
func NewDevelopersMetric() *DevelopersMetric
NewDevelopersMetric creates the developers metric.
func (*DevelopersMetric) Compute ¶
func (m *DevelopersMetric) Compute(input *TickData) []DeveloperData
Compute calculates developer statistics from tick data.
type IdentityAuditEntry ¶
IdentityAuditEntry represents a developer identity for auditing.
func GenerateIdentityAudit ¶
func GenerateIdentityAudit(report analyze.Report) []IdentityAuditEntry
GenerateIdentityAudit creates an audit list of developer identities.
type LanguageData ¶
type LanguageData struct {
Name string `json:"name" yaml:"name"`
TotalLines int `json:"total_lines" yaml:"total_lines"`
TotalContribution int `json:"total_contribution" yaml:"total_contribution"`
Contributors map[int]int `json:"contributors" yaml:"contributors"`
}
LanguageData contains computed data for a programming language.
type LanguagesMetric ¶
type LanguagesMetric struct {
metrics.MetricMeta
}
LanguagesMetric computes per-language statistics.
func NewLanguagesMetric ¶
func NewLanguagesMetric() *LanguagesMetric
NewLanguagesMetric creates the languages metric.
func (*LanguagesMetric) Compute ¶
func (m *LanguagesMetric) Compute(developers []DeveloperData) []LanguageData
Compute calculates language statistics from developer data.
type TickDevData ¶
type TickDevData struct {
// DevData maps commit hash hex to per-commit developer statistics.
DevData map[string]*CommitDevData
}
TickDevData is the per-tick aggregated payload stored in analyze.TICK.Data. It groups all per-commit developer data within one time bucket.