1use crate::check::{Check, Finding};
2use koala_core::invariant::Context;
3
4pub struct Registry {
5 checks: Vec<Box<dyn Check>>,
6}
7
8impl Registry {
9 pub fn empty() -> Self {
10 Self { checks: Vec::new() }
11 }
12
13 pub fn from_checks(checks: Vec<Box<dyn Check>>) -> Self {
14 Self { checks }
15 }
16
17 pub fn builtin() -> Self {
18 use crate::checks::{
19 adr_dormancy, adr_graph_clean, adr_no_delete, arch_claims, feature_acceptance,
20 feature_acceptance_complete, feature_adr_refs, feature_status_impl,
21 template_placeholder, tier1_integrity,
22 };
23 Self::from_checks(vec![
24 Box::new(feature_acceptance::FeatureAcceptanceTestRef),
25 Box::new(feature_acceptance_complete::FeatureAcceptanceComplete),
26 Box::new(feature_adr_refs::FeatureAdrRefs),
27 Box::new(feature_status_impl::FeatureStatusHasImpl),
28 Box::new(adr_dormancy::AdrDormancy),
29 Box::new(adr_graph_clean::AdrGraphClean),
30 Box::new(adr_no_delete::AdrNoDelete),
31 Box::new(tier1_integrity::Tier1Integrity),
32 Box::new(arch_claims::ArchClaims),
33 Box::new(template_placeholder::TemplatePlaceholder),
34 ])
35 }
36
37 pub fn checks(&self) -> impl Iterator<Item = &dyn Check> {
38 self.checks.iter().map(|c| c.as_ref())
39 }
40
41 pub fn len(&self) -> usize {
42 self.checks.len()
43 }
44
45 pub fn is_empty(&self) -> bool {
46 self.checks.is_empty()
47 }
48
49 pub fn run_all(&self, ctx: &Context) -> Vec<Finding> {
50 let mut out = Vec::new();
51 for c in &self.checks {
52 out.extend(c.run(ctx));
53 }
54 out
55 }
56}