#![cfg_attr(coverage_nightly, coverage(off))]
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum DefectSeverity {
P0Critical,
P1Performance,
P2Efficiency,
P3Minor,
}
impl std::fmt::Display for DefectSeverity {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::P0Critical => write!(f, "P0-Critical"),
Self::P1Performance => write!(f, "P1-Performance"),
Self::P2Efficiency => write!(f, "P2-Efficiency"),
Self::P3Minor => write!(f, "P3-Minor"),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DefectClass {
pub ticket_id: String,
pub description: String,
pub severity: DefectSeverity,
pub detection_method: String,
pub resolved: bool,
pub root_cause: Option<String>,
}
#[derive(Debug, Clone, Default)]
pub struct DefectTaxonomy {
patterns: HashMap<String, DefectClass>,
}
impl DefectTaxonomy {
#[must_use]
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn get(&self, ticket_id: &str) -> Option<&DefectClass> {
self.patterns.get(ticket_id)
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn all(&self) -> impl Iterator<Item = &DefectClass> {
self.patterns.values()
}
#[must_use]
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn len(&self) -> usize {
self.patterns.len()
}
#[must_use]
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn is_empty(&self) -> bool {
self.patterns.is_empty()
}
}
include!("cuda_simd_defects_patterns.rs");
include!("cuda_simd_defects_tests.rs");