Skip to main content

Module vcs

Module vcs 

Source
Available on crate feature vcs-git only.
Expand description

Change-history (VCS) metrics derived from version-control history: churn, commit frequency, author count / ownership dilution, bug- and security-fix history, and an ordinal composite risk score. See vcs::build_history_index.

Enable with the vcs Cargo feature (the umbrella over the current vcs-git backend, which is what the availability badge names). Change-history (VCS) metrics: per-file signals derived from version control history rather than the AST.

This is the project’s first metric family that is language-agnostic and not AST-derived (issue #328). It surfaces files most likely to harbour bugs or vulnerabilities using the signals the empirical literature most consistently backs — recent churn, commit frequency, author count and ownership dilution, bug- and security-fix history — combined into an ordinal risk_score.

§Layout

The generic surface (error, options, stats, identity, classify, score, hotspot, jit, and build_history_index) carries no backend reference, so a future backend (Mercurial, Jujutsu, …; issue #335) reuses it unchanged. Backend-specific code lives under the git module behind the vcs-git Cargo feature.

Two scoring granularities are offered: build_history_index ranks files at a ref (issue #328), while score_commit scores a single commit for just-in-time defect-induction risk (issue #331).

v1 deliberately omits a Backend trait: with a single backend it would be premature abstraction. build_history_index delegates to the one available backend; the trait is extracted when a second backend lands.

Re-exports§

pub use bus_factor::BUS_FACTOR_SCHEMA_VERSION;
pub use bus_factor::BusFactor;
pub use bus_factor::DirectoryBusFactor;
pub use bus_factor::GroupBusFactor;
pub use bus_factor::VcsAggregate;
pub use cache::CACHE_SCHEMA_VERSION;
pub use cache::CacheConfig;
pub use error::Error;
pub use identity::AuthorHashKey;
pub use jit::JIT_SCHEMA_VERSION;
pub use jit::JIT_SCORE_VERSION;
pub use jit::JitCommit;
pub use jit::JitContributions;
pub use jit::JitDiffContributions;
pub use jit::JitDiffReport;
pub use jit::JitDiffusion;
pub use jit::JitExperience;
pub use jit::JitFeatures;
pub use jit::JitHistory;
pub use jit::JitPurpose;
pub use jit::JitReport;
pub use jit::JitSize;
pub use jit::JitSource;
pub use options::FileTypeScope;
pub use options::Options;
pub use options::RiskFormula;
pub use options::parse_window;
pub use stats::Stats;
pub use trend::TREND_SCHEMA_VERSION;
pub use trend::Trend;
pub use trend::TrendDelta;
pub use trend::TrendDeltas;
pub use git::BlameSession;
pub use git::LineSpan;
pub use git::PerFunctionBlame;

Modules§

bus_factor
Directory- and repo-level bus factor (a.k.a. truck factor) over a change-history walk, via the Avelino Degree-of-Authorship (DoA) heuristic (issue #332).
cache
Persistent change-history cache, keyed by HEAD SHA and repo identity (issue #334).
classify
Commit-message classification: bug-fix, security-fix, and revert detection via curated keyword regexes.
entropy
Shannon-entropy machinery shared by the two process-entropy signals added in issue #330.
error
Error type for the change-history (VCS) metrics pipeline.
git
The vcs-git backend: a gix-powered history walk.
hotspot
Complexity × churn “hotspot” score (Tornhill; Nagappan & Ball).
identity
Canonical author identity and bot-author detection.
jit
Just-in-time (commit-level) defect-induction risk scoring (issue #331).
options
Configuration for a change-history walk.
score
Composite risk-score formulas.
stats
Per-file change-history statistics: the public Stats output and the internal Accumulator that the backend feeds during a walk.
trend
Historical metric trend: the change-history (VCS) metrics computed at several points in time, so a consumer can see whether a file’s risk is improving or degrading rather than only its risk now (issue #333).

Structs§

HistoryIndex
The result of one history walk: per-file Stats keyed by repository-relative path, plus walk-level metadata.

Functions§

build_history_index
Walk the change history rooted at root and build a per-file HistoryIndex.
build_history_index_cached
Like build_history_index, but reuse and update the persistent change-history cache per config (issue #334).
build_trend
Sample the change-history metrics at points evenly-spaced moments across span_secs, ending at options.as_of (or wall-clock now), building a trend::Trend time series (issue #333).
parse_timestamp
Parse an --as-of timestamp into Unix seconds.
rank_by_risk
Rank entries by descending risk score, breaking ties on the file path (ascending), then truncate to the top top (0 = keep all).
score_commit
Score a single commit for just-in-time defect-induction risk (issue #331).
score_diff
Score an arbitrary unified diff for just-in-time defect-induction risk (issue #580).
workdir_root
Discover the working-tree root of the repository containing path.