#![cfg_attr(coverage_nightly, coverage(off))]
pub mod ascii_viz;
pub mod data_science;
pub mod types;
pub use ascii_viz::*;
pub use data_science::DataScienceAnalyzer;
pub use types::*;
use std::fmt::Write;
pub struct RichReporter {
config: ReportConfig,
report: RichReport,
analyzer: DataScienceAnalyzer,
dependencies: Vec<(String, String)>,
metric_history: Vec<(String, Vec<(i64, f64)>)>,
}
impl RichReporter {
pub fn new(config: ReportConfig) -> Self {
let analyzer = DataScienceAnalyzer::new(
config.k_clusters,
config.pagerank_damping,
config.louvain_resolution,
config.anomaly_threshold,
);
RichReporter {
config,
report: RichReport::new("PMAT Report", ""),
analyzer,
dependencies: Vec::new(),
metric_history: Vec::new(),
}
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn with_title(mut self, title: impl Into<String>) -> Self {
self.report.title = title.into();
self
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn with_project(mut self, project: impl Into<String>) -> Self {
self.report.project = project.into();
self
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn add_finding(&mut self, finding: Finding) {
self.report.findings.push(finding);
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn add_findings(&mut self, findings: impl IntoIterator<Item = Finding>) {
self.report.findings.extend(findings);
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn add_dependency(&mut self, from: impl Into<String>, to: impl Into<String>) {
self.dependencies.push((from.into(), to.into()));
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn add_metric_history(&mut self, name: impl Into<String>, data: Vec<(i64, f64)>) {
self.metric_history.push((name.into(), data));
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "score_range")]
pub fn set_quality_score(&mut self, score: f64) {
self.report.quality_score = score;
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn add_summary(&mut self, key: impl Into<String>, value: impl Into<String>) {
self.report.summary.insert(key.into(), value.into());
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn add_recommendation(&mut self, recommendation: impl Into<String>) {
self.report.recommendations.push(recommendation.into());
}
}
include!("rich_reporter_analysis.rs");
include!("rich_reporter_rendering.rs");
include!("rich_reporter_tests.rs");