use crate::spec::op_registry;
use crate::OpSpec;
use super::archetype_check::check_archetypes;
use super::category_check::check_category;
use super::docs_check::check_docs_path;
use super::error::CoverageError;
use super::law_check::{check_declared_laws, check_laws};
use super::oracle_check::check_oracle;
use super::row_check::check_rows;
use super::signature_check::check_signature;
use super::version_check::check_since_version;
#[inline]
pub fn verify_coverage() -> Result<(), Vec<CoverageError>> {
let specs = op_registry::all_specs();
verify_specs(&specs)
}
#[inline]
pub fn verify_specs(specs: &[OpSpec]) -> Result<(), Vec<CoverageError>> {
let mut errors = Vec::new();
let mut seen_ids = std::collections::HashSet::new();
for spec in specs {
if !seen_ids.insert(spec.id.to_string()) {
errors.push(CoverageError::DuplicateOpId {
op_id: spec.id.to_string(),
});
continue;
}
check_category(spec, &mut errors);
check_signature(spec, &mut errors);
check_laws(spec, &mut errors);
check_declared_laws(spec, &mut errors);
check_oracle(spec, &mut errors);
check_rows(spec, &mut errors);
check_docs_path(spec, &mut errors);
check_since_version(spec, &mut errors);
check_archetypes(spec, &mut errors);
}
if errors.is_empty() {
Ok(())
} else {
Err(errors)
}
}