analysis

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatAbsChurn

func FormatAbsChurn(results []ChurnResult, _ model.Options) [][]string

func FormatAge

func FormatAge(results []AgeResult, _ model.Options) [][]string

func FormatAuthorChurn

func FormatAuthorChurn(results []ChurnResult, _ model.Options) [][]string

func FormatAuthors

func FormatAuthors(results []AuthorsResult, _ model.Options) [][]string

func FormatBusFactor added in v1.1.0

func FormatBusFactor(results []BusFactorResult, _ model.Options) [][]string

func FormatCommunication

func FormatCommunication(results []CommunicationResult, _ model.Options) [][]string

func FormatCoupling

func FormatCoupling(results []CouplingResult, opts model.Options) [][]string

func FormatEntityChurn

func FormatEntityChurn(results []ChurnResult, _ model.Options) [][]string

func FormatEntityEffort

func FormatEntityEffort(results []EntityEffortResult, _ model.Options) [][]string

func FormatEntityOwnership

func FormatEntityOwnership(results []EntityOwnershipResult, _ model.Options) [][]string

func FormatFragmentation

func FormatFragmentation(results []FragmentationResult, _ model.Options) [][]string

func FormatIdentity

func FormatIdentity(results []model.Commit, _ model.Options) [][]string

func FormatKnowledgeLoss added in v1.1.0

func FormatKnowledgeLoss(results []KnowledgeLossResult, _ model.Options) [][]string

func FormatMainDev

func FormatMainDev(results []ContributorResult, _ model.Options) [][]string

func FormatMainDevByRevs

func FormatMainDevByRevs(results []ContributorResult, _ model.Options) [][]string

func FormatRefactoringMainDev

func FormatRefactoringMainDev(results []ContributorResult, _ model.Options) [][]string

func FormatRevisions

func FormatRevisions(results []RevisionsResult, _ model.Options) [][]string

func FormatRework added in v1.1.0

func FormatRework(results []ReworkResult, _ model.Options) [][]string

func FormatStatistics

func FormatStatistics(results []StatisticsResult, _ model.Options) [][]string

func FormatSumOfCoupling

func FormatSumOfCoupling(results []SumOfCouplingResult, _ model.Options) [][]string

func FormatSummary

func FormatSummary(result SummaryResult, _ model.Options) [][]string

func Identity

func Identity(commits []model.Commit, _ model.Options) []model.Commit

Identity passes commits through unchanged, producing a raw revision listing.

Types

type AgeResult

type AgeResult struct {
	Entity    string
	AgeMonths int
}

func Age

func Age(commits []model.Commit, opts model.Options) []AgeResult

Age calculates months since last modification for each entity.

type AuthorsResult

type AuthorsResult struct {
	Entity  string
	Authors int
	Revs    int
}

func Authors

func Authors(commits []model.Commit, _ model.Options) []AuthorsResult

Authors counts the distinct authors and revisions for each entity.

type BusFactorResult added in v1.1.0

type BusFactorResult struct {
	Entity    string
	BusFactor int
	TopOwners []string
	Ownership float64 // combined share of TopOwners, as a percentage
}

func BusFactor added in v1.1.0

func BusFactor(commits []model.Commit, _ model.Options) []BusFactorResult

BusFactor returns, per entity, the fewest authors who together own more than 50% of its added lines. Entities with no added lines are skipped.

type ChurnResult

type ChurnResult struct {
	Key     string
	Added   int
	Deleted int
	Commits int
}

ChurnResult holds added/deleted line totals and distinct commit count for one key. Used by AbsChurn (key=date), AuthorChurn (key=author), and EntityChurn (key=entity).

func AbsChurn

func AbsChurn(commits []model.Commit, _ model.Options) []ChurnResult

AbsChurn returns lines added/deleted aggregated by date.

func AuthorChurn

func AuthorChurn(commits []model.Commit, _ model.Options) []ChurnResult

AuthorChurn returns lines added/deleted aggregated by author.

func EntityChurn

func EntityChurn(commits []model.Commit, _ model.Options) []ChurnResult

EntityChurn returns lines added/deleted aggregated by entity, sorted by added desc.

type CommunicationResult

type CommunicationResult struct {
	Author   string
	Peer     string
	Shared   int
	Average  int
	Strength int
}

func Communication

func Communication(commits []model.Commit, _ model.Options) []CommunicationResult

Communication maps team collaboration needs based on shared entities.

Algorithm (mirrors the original Clojure implementation):

  1. Find distinct authors per entity.
  2. For each entity, generate all 2-selections (with replacement) of its authors: [A,A], [A,B], [B,A], [B,B] etc.
  3. Count frequencies across all entities.
  4. Self-pairs [A,A] give A's total entity count ("total commits").
  5. Non-self pairs [A,B] give the count of entities both A and B touched ("shared").
  6. average = ceil((self_A + self_B) / 2)
  7. strength = int((shared / average) * 100)

type ContributorResult

type ContributorResult struct {
	Entity      string
	Contributor string
	Count       int
	Total       int
	Ownership   float64
}

ContributorResult holds the top contributor per entity and their ownership percentage. Used by MainDev, RefactoringMainDev, and MainDevByRevs.

func MainDev

func MainDev(commits []model.Commit, _ model.Options) []ContributorResult

MainDev returns the author with the most lines added per entity.

func MainDevByRevs

func MainDevByRevs(commits []model.Commit, _ model.Options) []ContributorResult

MainDevByRevs returns the author with the most revisions per entity.

func RefactoringMainDev

func RefactoringMainDev(commits []model.Commit, _ model.Options) []ContributorResult

RefactoringMainDev returns the author with the most lines deleted per entity.

type CouplingResult

type CouplingResult struct {
	Entity  string
	Coupled string
	Degree  int
	AvgRevs int
	RevA    int
	RevB    int
	Shared  int
}

func Coupling

func Coupling(commits []model.Commit, opts model.Options) []CouplingResult

Coupling detects modules that tend to change together (temporal coupling).

type EntityEffortResult

type EntityEffortResult struct {
	Entity     string
	Author     string
	AuthorRevs int
	TotalRevs  int
}

func EntityEffort

func EntityEffort(commits []model.Commit, _ model.Options) []EntityEffortResult

EntityEffort returns revision count per (entity, author) pair.

type EntityOwnershipResult

type EntityOwnershipResult struct {
	Entity  string
	Author  string
	Added   int
	Deleted int
}

func EntityOwnership

func EntityOwnership(commits []model.Commit, _ model.Options) []EntityOwnershipResult

EntityOwnership returns churn per (entity, author) pair.

type FragmentationResult

type FragmentationResult struct {
	Entity    string
	Fractal   float64
	TotalRevs int
}

func Fragmentation

func Fragmentation(commits []model.Commit, _ model.Options) []FragmentationResult

Fragmentation calculates the fractal value (author distribution) per entity. fractal = 1 - Σ(author_revs/total_revs)² 0 = single author, approaching 1 = many equal contributors.

type KnowledgeLossResult added in v1.1.0

type KnowledgeLossResult struct {
	Entity      string
	FormerAdded int
	TotalAdded  int
	Loss        float64 // FormerAdded / TotalAdded, as a percentage
}

func KnowledgeLoss added in v1.1.0

func KnowledgeLoss(commits []model.Commit, opts model.Options) []KnowledgeLossResult

KnowledgeLoss returns, per entity, the share of added lines written by authors in opts.FormerAuthors. Entities with no added lines are skipped.

type RevisionsResult

type RevisionsResult struct {
	Entity string
	Revs   int
}

func Revisions

func Revisions(commits []model.Commit, _ model.Options) []RevisionsResult

Revisions counts the number of revisions for each entity.

type ReworkResult added in v1.1.0

type ReworkResult struct {
	Entity   string
	Added    int     // judged lines added to the entity
	Reworked int     // of those, lines removed or rewritten within the window
	Ratio    float64 // Reworked / Added, as a percentage
}

func Rework added in v1.1.0

func Rework(commits iter.Seq2[gitdiff.Commit, error], opts model.Options) ([]ReworkResult, error)

Rework reports, per entity, the share of added lines that were removed or substantially rewritten within opts.ReworkWindow of landing.

commits must be in chronological (oldest-first) order along a single line of history, as produced by

git log --reverse --first-parent --diff-merges=first-parent -p -U0 --no-renames

so that applying each commit's hunks in turn reproduces every file's contents. Rework tracks, for every line, the commit (entity and time) that introduced it. A line counts as:

  • added, if it is non-blank and its window has fully elapsed by opts.ReworkTimeNow (younger lines cannot be judged yet, so they are left out of both counts). A merge's first-parent diff counts as landing the merged branch's lines at the merge's time, so merge-commit, squash and rebase workflows are measured alike;
  • reworked, if a later commit within the window removes it without that commit re-adding the same text elsewhere (a move, compared ignoring whitespace, even across files) and without replacing it in place with a line at least minEditSimilarity token-similar (a small edit).

A moved or lightly edited line keeps its original provenance, so it is still judged against its original landing time. Lines that predate the analyzed history are untracked and never counted.

type StatisticsResult

type StatisticsResult struct {
	Metric string
	Count  int
	Min    float64
	Q1     float64
	Median float64
	Q3     float64
	Max    float64
	Mean   float64
	Stddev float64
}

func Statistics

func Statistics(commits []model.Commit, _ model.Options) []StatisticsResult

Statistics computes descriptive statistics (count/min/q1/median/q3/max/ mean/sample-stddev) for a curated set of core metrics. It intentionally ignores opts: this is a whole-codebase health report, not a filtered query, so none of model.Options' threshold fields (MinRevs, MaxChangesetSize, etc.) apply. Entity/author remapping via -g/-p still applies normally, since runAnalysis rewrites commits before Statistics ever sees them.

type SumOfCouplingResult

type SumOfCouplingResult struct {
	Entity string
	Soc    int
}

func SumOfCoupling

func SumOfCoupling(commits []model.Commit, opts model.Options) []SumOfCouplingResult

SumOfCoupling aggregates coupling counts per entity (how many co-changes it participates in).

type SummaryResult

type SummaryResult struct {
	Commits         int
	Entities        int
	EntitiesChanged int
	Authors         int
}

func Summary

func Summary(commits []model.Commit, _ model.Options) SummaryResult

Summary computes repo-wide totals: number of commits, entities, entities changed, and authors.

Jump to

Keyboard shortcuts

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