Skip to main content

build_grouped_duplication_json

Function build_grouped_duplication_json 

Source
pub fn build_grouped_duplication_json(
    report: &DuplicationReport,
    grouping: &DuplicationGrouping,
    root: &Path,
    elapsed: Duration,
    explain: bool,
) -> Result<Value, Error>
Expand description

Build a grouped duplication JSON envelope when --group-by is active.

The envelope keeps the project-level duplication payload (stats, clone_groups, clone_families) at the top level so consumers that ignore grouping still see project-wide aggregates, and adds:

  • grouped_by: the resolver mode ("owner", "directory", "package", "section").
  • groups: one entry per resolver bucket. Each entry carries its own per-group stats (dedup-aware, computed over the FULL group before --top truncation), clone_groups (each tagged with primary_owner and per-instance owner), and clone_families.

Paths inside groups are relativised the same way as the project-level payload via strip_root_prefix.

ยงErrors

Returns an error if either the project report or any group cannot be serialised to JSON.