use crate::{Document, Finding, markdown::is_slug};
pub const CORE_RELS: &[&str] = &[
"relates-to",
"part-of",
"has-part",
"depends-on",
"depended-on-by",
"references",
"referenced-by",
"supersedes",
"superseded-by",
"implements",
"implemented-by",
"tests",
"tested-by",
"contradicts",
];
pub fn check(doc: &Document) -> Vec<Finding> {
let mut findings = Vec::new();
for link in &doc.core.links {
if CORE_RELS.contains(&link.rel.as_str()) {
continue;
}
if is_slug(&link.rel) {
findings.push(Finding::warning(
doc.path.clone(),
Some(link.line),
"SOKF_VALIDATION_4",
format!(
"`rel: {}` is outside the core set, so consumers read it as `relates-to`",
link.rel
),
));
} else {
findings.push(Finding::error(
doc.path.clone(),
Some(link.line),
"SOKF_FORMAT_52",
format!("`rel: {}` is not lowercase kebab-case", link.rel),
));
}
}
findings
}