Skip to main content

drft/analyses/
mod.rs

1pub mod betweenness;
2pub mod bridges;
3pub mod change_propagation;
4pub mod connected_components;
5pub mod degree;
6pub mod depth;
7pub mod graph_boundaries;
8pub mod graph_stats;
9pub mod pagerank;
10pub mod scc;
11pub mod transitive_reduction;
12
13use crate::config::Config;
14use crate::graph::Graph;
15use crate::lockfile::Lockfile;
16use std::path::Path;
17
18/// Context passed to every analysis, providing access to the graph,
19/// filesystem root, config, and optional lockfile.
20pub struct AnalysisContext<'a> {
21    pub graph: &'a Graph,
22    pub root: &'a Path,
23    pub config: &'a Config,
24    pub lockfile: Option<&'a Lockfile>,
25}
26
27/// An analysis computes structured data about the graph.
28/// Rules consume analysis results and map them to diagnostics.
29/// Metrics extract scalar values from analysis results.
30/// See [`docs/analyses`](../../docs/analyses/README.md) for conceptual documentation on each analysis.
31pub trait Analysis {
32    type Output: serde::Serialize;
33
34    fn name(&self) -> &str;
35
36    fn run(&self, ctx: &AnalysisContext) -> Self::Output;
37}