pub mod attrs;
pub mod cycles;
pub mod finalize;
pub mod hk;
pub mod level_graph;
pub mod relativize;
pub mod serialize;
pub mod snapshot;
pub mod stats;
pub use attrs::{num_attr, round_sig3};
pub use cycles::annotate_cycles;
pub use finalize::finalize_graph;
pub use hk::annotate_hk;
pub use level_graph::{CycleGroup, LevelGraph, LevelUi};
pub use relativize::{relativize_graph, relativize_level};
pub use serialize::{to_canonical_string, to_canonical_string_pretty};
pub use snapshot::{GitInfo, Snapshot, StageTime};
pub use stats::compute_stats;
use code_ranker_plugin_api::{
attrs::ValueType,
level::{AttributeGroup, AttributeSpec, Direction, SpecRow, attr_dict, group},
};
use std::collections::BTreeMap;
pub fn coupling_specs() -> (
BTreeMap<String, AttributeSpec>,
BTreeMap<String, AttributeGroup>,
) {
let specs = attr_dict(vec![
(
"fan_in",
SpecRow {
group: "coupling",
label: "Fan-in",
name: "Fan-in",
short: "Fan-in",
description: "Number of nodes that depend on this one. High fan-in means broadly reused.",
..Default::default()
},
),
(
"fan_out",
SpecRow {
group: "coupling",
label: "Fan-out",
name: "Fan-out",
short: "Fan-out",
description: "Number of nodes this one depends on. High fan-out means many \
dependencies. External-library edges are counted separately.",
..Default::default()
},
),
(
"fan_out_external",
SpecRow {
group: "coupling",
label: "Fan-out (external)",
description: "Number of distinct external libraries this node depends on.",
..Default::default()
},
),
(
"hk",
SpecRow {
group: "coupling",
value_type: ValueType::Float,
label: "HK",
name: "Henry–Kafura",
short: "HK",
description: "Henry–Kafura — combines unit size with incoming/outgoing coupling \
(internal edges only).",
formula: "sloc × (fan_in × fan_out)²",
calc: "sloc * (fan_in * fan_out) ** 2",
direction: Direction::LowerBetter,
abbreviate: true,
},
),
(
"cycle",
SpecRow {
value_type: ValueType::Str,
label: "Cycle",
short: "Cycle",
description: "Cycle kind this node participates in.",
..Default::default()
},
),
]);
let mut groups = BTreeMap::new();
groups.insert(
"coupling".to_string(),
group("Coupling", "Internal coupling (Henry-Kafura)"),
);
(specs, groups)
}