linecheck 1.1.0

A fast, configurable tool that warns or errors when files exceed a set line count
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use glob::Pattern;
use std::path::Path;

pub(super) fn excluded(path: &Path, root: Option<&Path>, pats: &[Pattern]) -> bool {
    if let Some(root) = root
        && let Ok(rel) = path.strip_prefix(root)
    {
        let s = rel.to_string_lossy();
        if pats.iter().any(|p| p.matches(&s)) {
            return true;
        }
    }
    let s = path.to_string_lossy();
    let n = s.strip_prefix("./").unwrap_or(&s);
    pats.iter().any(|p| p.matches(n) || p.matches(&s))
}