Skip to main content

Module clone_coupling

Module clone_coupling 

Expand description

Clone-coupling intersection. The strategic differentiator vs every existing clone detector: only flag clones that ALSO change together at Fisher-significant rates. CodeScene calls this “X-Ray”; we ship the same analytical pattern with our published-formula transparency.

Algorithm (locked from the research brief):

  1. Any-pair intersection. A clone family is “live” if any two members of the same clone_group_id are themselves a coupling-significant file pair (Fisher exact p < threshold).
  2. False-positive mitigations (5 per research brief):
    • min fragment size: node_count ≥ opts.min_clone_node_count (default 30)
    • min shared revs: shared_revs ≥ opts.min_clone_shared_revs (default 3)
    • similarity floor: similarity ≥ opts.clone_similarity_floor (default 0.70)
    • exclude generated/vendored paths (handled by --exclude + .codeloreignore)
    • optional same-dir skip (opts.clone_skip_same_dir, default true).

Research basis: see docs/research-foundations.md entry “clone-coupling” (Tornhill, Software Design X-Rays, 2018 — X-Ray analysis; CodeScene productisation). CodeLore ships the same analytical pattern with published-formula transparency.

NOTE: This analysis assumes extract_clones_at_head populates the clones table during FactsDb::ingest) has shipped. Before §4 lands, the JOIN returns 0 rows because the clones table stays empty even though the --analysis clones CLI path (which runs ad-hoc) produces rows. Tests in tests/clone_coupling_test.rs populate the clones table programmatically to validate the SQL independently.

Structs§

CloneCouplingRow
One clone-coupling finding. A pair of files from the same clone family that also co-change at Fisher-significant rates. Sorted by combined_score desc so PR-review tooling surfaces the most actionable findings first.

Functions§

run_clone_coupling
Run the clone-coupling analysis. Returns rows sorted by combined_score descending.