impl PopperFinding {
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn positive(message: &str) -> Self {
Self {
severity: FindingSeverity::Positive,
message: message.to_string(),
location: None,
impact: 0.0,
}
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn info(message: &str) -> Self {
Self {
severity: FindingSeverity::Info,
message: message.to_string(),
location: None,
impact: 0.0,
}
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn warning(message: &str, impact: f64) -> Self {
Self {
severity: FindingSeverity::Warning,
message: message.to_string(),
location: None,
impact,
}
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn critical(message: &str, impact: f64) -> Self {
Self {
severity: FindingSeverity::Critical,
message: message.to_string(),
location: None,
impact,
}
}
}
impl PopperRecommendation {
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn new(
category: &str,
description: &str,
priority: RecommendationPriority,
potential_percent: f64,
) -> Self {
Self {
category: category.to_string(),
description: description.to_string(),
priority,
potential_percent,
command: None,
}
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn with_command(mut self, cmd: &str) -> Self {
self.command = Some(cmd.to_string());
self
}
}
impl fmt::Display for AnalysisStatus {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
AnalysisStatus::Pass => write!(f, "PASS"),
AnalysisStatus::Partial => write!(f, "PARTIAL"),
AnalysisStatus::Fail => write!(f, "FAIL"),
}
}
}
impl PopperMetadata {
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn new(project_name: String) -> Self {
Self {
timestamp: chrono::Utc::now().to_rfc3339(),
project_name,
version: "1.1.0".to_string(),
project_path: None,
}
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "path_exists")]
pub fn with_path(mut self, path: PathBuf) -> Self {
self.project_path = Some(path);
self
}
}