use crate::linter::{Diagnostic, LintContext, Rule};
const MIN_CONNECTIONS: usize = 2;
pub struct UnconnectedNetRule;
impl Rule for UnconnectedNetRule {
fn name(&self) -> &'static str {
"unconnected_net"
}
fn check(&self, ctx: &LintContext<'_>) -> Vec<Diagnostic> {
ctx.netlist
.floating_nets()
.filter(|net| net.is_defined)
.map(|net| Diagnostic {
rule: self.name().to_string(),
message: format!(
"net \"{}\" has only {} connection(s) (minimum {MIN_CONNECTIONS}): it is floating",
net.display_name(),
net.endpoints.len()
),
help: Some(
"every net must connect at least two pads/ports — complete the routing in tscircuit"
.to_string(),
),
..Default::default()
})
.collect()
}
}