Skip to main content

Options

Struct Options 

pub struct Options {
Show 40 fields pub repo_path: PathBuf, pub after: Option<Date>, pub before: Option<Date>, pub group_file: Option<PathBuf>, pub team_map_file: Option<PathBuf>, pub min_revs: u32, pub min_shared_revs: u32, pub min_coupling_pct: u8, pub max_coupling_pct: u8, pub max_changeset_size: u32, pub fisher_significance: f64, pub message_regex: Option<String>, pub age_time_now: Option<Date>, pub rows_limit: Option<u32>, pub include_merges: bool, pub strict_grouping: bool, pub complexity_sample: ComplexitySample, pub explain: bool, pub use_canonical_lineage: bool, pub min_clone_node_count: u32, pub exclude_patterns: Vec<String>, pub include_ignored: bool, pub departed_threshold_days: u32, pub min_clone_shared_revs: u32, pub clone_similarity_floor: f64, pub clone_skip_same_dir: bool, pub min_soc: Option<u32>, pub time_bucket: Option<TimeBucket>, pub code_maat_compat: bool, pub fdr_correction: bool, pub window_days: u32, pub knowledge_model: String, pub rework_window_days: u32, pub release_tag_glob: String, pub target: Option<String>, pub calibration: Option<PathBuf>, pub defect_calibration: Option<PathBuf>, pub allow_foreign_calibration: bool, pub head_only_ingest: bool, pub temp_dir: Option<PathBuf>,
}

Fields§

§repo_path: PathBuf§after: Option<Date>§before: Option<Date>§group_file: Option<PathBuf>§team_map_file: Option<PathBuf>§min_revs: u32§min_shared_revs: u32§min_coupling_pct: u8§max_coupling_pct: u8§max_changeset_size: u32§fisher_significance: f64§message_regex: Option<String>§age_time_now: Option<Date>§rows_limit: Option<u32>§include_merges: bool§strict_grouping: bool§complexity_sample: ComplexitySample§explain: bool

Print the DuckDB query plan + raw SQL to stderr before running the analysis. Set via --explain. Cosmetic — not part of the canonical cache key.

§use_canonical_lineage: bool

When true (default), aggregations follow file renames through changes.rename_from. A file’s pre-rename history is merged onto its current canonical path. When false, every commit’s path is treated literally — matches code-maat’s historic behaviour (it uses --no-renames). --code-maat-compat implies use_canonical_lineage = false for bit-for-bit parity.

§min_clone_node_count: u32§exclude_patterns: Vec<String>§include_ignored: bool

When false (default), paths_filter::PathsFilter auto-respects .gitignore, .git/info/exclude, and .codeloreignore at the repo root so vendored deps (node_modules), build outputs (target, dist), lockfiles, locales, etc. don’t show up in hotspots or skew Kamei features. Set to true (via --include-ignored) to analyse everything regardless of those files.

§departed_threshold_days: u32

Knowledge-islands: an author is considered “departed” if their most recent commit anywhere in the repo is older than this many days at the anchor moment. Default 90. See constants::DEFAULT_DEPARTED_THRESHOLD_DAYS for the rationale on this default.

§min_clone_shared_revs: u32

Minimum shared_revs for a clone pair to count as “live”. Below this floor the Fisher test is unreliable (small contingency-table cells). Default 3.

§clone_similarity_floor: f64

Minimum similarity for a clone pair to enter the coupling intersection. SourcererCC’s BCB benchmark found precision/recall optimum at 0.70. Default 0.70. Type 1 + Type 2 always = 1.0 today; this matters once Type 3 (MinHash) lands.

§clone_skip_same_dir: bool

Skip clone pairs whose two files share the same parent directory (intentional structural mirroring like foo_test.rsfoo.rs). Default true.

§min_soc: Option<u32>

SoC threshold for the soc analysis. None = drop solo commits (default 1). Modern replacement for code-maat’s overloaded use of --min-revs to mean “minimum SoC sum” in this one analysis.

§time_bucket: Option<TimeBucket>

Time-bucket granularity for coupling-family analyses. None = raw commit grain (no bucketing). When set, coupling and friends aggregate changes by the bucket-truncated date.

§code_maat_compat: bool

Migration-helper flag. When true, flips internal defaults to match legacy code-maat output bit-for-bit (lying column headers, arbitrary tiebreaks, etc.). Off by default — the modern surface is the recommendation; this flag exists so users with dashboards parsing code-maat CSV verbatim aren’t broken on day one of migration.

§fdr_correction: bool

Apply a Benjamini-Hochberg false-discovery-rate correction across the whole family of Fisher-tested coupling pairs instead of the per-pair fisher_p < fisher_significance gate. Off by default — the per-test gate is unchanged. --code-maat-compat still bypasses both gates.

§window_days: u32

Trailing window in days for activity-scoped analyses. Anchored to the repo’s last commit date (not wall-clock time) so results are reproducible on old or archived repos. Valid range: 1–3650. Default: 90. Set via --window-days.

§knowledge_model: String

Knowledge model for bus-factor. Valid values: "commits" (default, Filatov 2010 — greedy coverage of ≥80% of commits) or "doe" (Cury & Avelino SBES’24 truck-factor procedure — greedy removal of the author with the most expert files until >50% of files lack an expert). Set via --knowledge-model.

§rework_window_days: u32

Hunk-overlap window for rework detection in delivery-metrics. Pairs of hunks touching the same path where the second commit’s author-date falls within this many days of the first are counted as rework candidates. Valid range: 1–365. Default: 21. Set via --rework-window-days.

§release_tag_glob: String

Glob pattern for filtering release tags in release-cadence. Only tags whose short name matches this glob are included. Must be non-empty. Default: "v*". Set via --release-tag-glob.

§target: Option<String>

Target file path for analyses that operate on a single file. Currently used only by function-xray. Set via --target. Validation that the value is present when required lives in the dispatch arm, not Options::validate, to avoid cross-analysis coupling.

§calibration: Option<PathBuf>

Corpus-calibration artifact for the code-health corpus-percentile lens. Some(path) overrides the embedded world artifact with a hand-built or org-specific one; None falls back to the embedded artifact (or no lens when that is a placeholder). A per-invocation selector that never affects ingest, so canonical_json drops it from the cache key and instead hashes its content into calibration_digest for provenance. Set via --calibration.

§defect_calibration: Option<PathBuf>

Own-repo defect-calibration artifact (defects.calib.json, built with codelore calibrate-defects) whose smell weights replace the built-in code-health defaults for this run. Like calibration, a per-invocation selector that never affects ingest: canonical_json drops the path and hashes the file content into defect_calibration_digest. Set via --defect-calibration.

§allow_foreign_calibration: bool

Skip the repo-identity guard when deliberately applying a defect-calibration artifact whose root-commit identity does not match this repository — e.g. reusing one repository’s calibration on a genuinely different repo, or a shallow / non-git checkout whose root commit is unreachable (so the identity falls back to the path and no longer matches). Set via --allow-foreign-calibration.

§head_only_ingest: bool

Internal ingest mode used by codelore calibrate: populate only the HEAD-time complexity and import facts (entities, complexity_metrics, imports) and leave every history table (commits, changes, hunks, …) empty. The full commit-history walk — and the kamei/clones passes it feeds — is skipped entirely; this also lets calibrate ingest shallow (depth-1) checkouts, which the commit walker cannot traverse. Not exposed as a CLI flag. Serialized like every other field, so canonical_json keys head-only cache entries apart from full ones.

§temp_dir: Option<PathBuf>

Override the DuckDB spill directory (the temp_directory PRAGMA target used once a query exceeds the internal memory ceiling — see constants::DEFAULT_DUCKDB_MEMORY_LIMIT). When None, facts::FactsDb defaults to a subdirectory of the cache root, or the system temp directory when there is no cache root in play (e.g. --no-cache). An environment/spill selector — it changes where DuckDB writes scratch files, never any row an analysis reads, so canonical_json drops it from the cache key like target and rows_limit. Set via --temp-dir; validated as an existing writable directory in Options::validate.

Implementations§

§

impl Options

pub fn canonical_json(&self) -> Value

Stable JSON-serialized snapshot of the full struct, used for cache keying and provenance manifest recording.

Adding a new field to Options automatically propagates to BOTH the cache key and the provenance manifest with zero per-field maintenance — fixes a historical drift where new fields silently weren’t hashed.

Normalizations applied to keep the canonical form stable:

  • exclude_patterns is sorted (insertion order from CLI flags vs. .codeloreignore parsing doesn’t perturb the form).
  • rows_limit is dropped (cosmetic — affects only output truncation, not the underlying data; setting --rows 10 on a cached analysis should still hit the cache).
§Panics

Panics only if Options ever gains a field whose type does not implement Serialize. Caught at compile time via the derive on the struct; this panic is unreachable in well-formed code.

pub fn with_no_row_limit(&self) -> Self

Clone with rows_limit = None. Use this WHENEVER a composite analysis invokes another analysis as an internal step (e.g. code-health and clone-coupling both invoke run_coupling to materialize the global coupling graph). Without this wrapper, --rows 10 flows into the inner SQL’s LIMIT ?, the inner result truncates to the top 10 pairs, and the composite result is computed over that arbitrary subset — e.g. coupling-centrality scores end up counting partners from a 10-pair sliver of the full graph. Worse: canonical_json deliberately drops rows_limit from the cache key (because the user-visible row-cap is cosmetic), so the corrupted result gets cached under the no-row-limit cache key and poisons subsequent runs.

pub fn for_clone_coupling_inner_coupling(&self) -> Self

Like with_no_row_limit, but also lowers min_shared_revs to at most min_clone_shared_revs. Used by clone-coupling’s internal call to run_coupling.

Without this override, the inner coupling call applies the default min_shared_revs = 5 even though clone-coupling’s own floor is min_clone_shared_revs = 3. Clone pairs that co-changed exactly 3 or 4 times were silently dropped by the inner call — clone-coupling then filtered the (already trimmed) result by min_clone_shared_revs, but the missing pairs were already gone.

The min-of-both semantics is the safer choice: if a user explicitly LOWERED --min-shared-revs below min-clone-shared-revs, honour that; if they didn’t, drop the floor to the clone-coupling threshold so we don’t lose anything.

pub fn validate(&self) -> Result<()>

Check cross-field invariants. Caller (typically the CLI boundary) runs this once after constructing Options so pathological flag combinations fail loudly instead of silently producing empty output. Each invariant catches a real footgun from the CLI surface.

§Errors

Returns crate::CodeLoreError::InvalidOptions (exit-2 configuration-error category) with a message naming the offending field pair.

Trait Implementations§

§

impl Clone for Options

§

fn clone(&self) -> Options

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Options

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl Default for Options

§

fn default() -> Self

Returns the “default value” for a type. Read more
§

impl Serialize for Options

§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more