refactor(xatu): narrow lint rule set
This commit was merged in pull request #84.
This commit is contained in:
@@ -1,13 +1,7 @@
|
||||
use crate::FileId;
|
||||
use crate::ast;
|
||||
use crate::rules::deprecated_to_path::DeprecatedToPath;
|
||||
use crate::rules::empty_inherit::EmptyInherit;
|
||||
use crate::rules::empty_let_in::EmptyLetIn;
|
||||
use crate::rules::unquoted_uri::UnquotedUri;
|
||||
|
||||
pub mod deprecated_to_path;
|
||||
pub mod empty_inherit;
|
||||
pub mod empty_let_in;
|
||||
pub mod unquoted_uri;
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -33,6 +27,7 @@ impl std::fmt::Display for Diagnostic {
|
||||
}
|
||||
}
|
||||
|
||||
#[expect(dead_code, reason = "retained for planned node rules")]
|
||||
pub trait NodeRule {
|
||||
type Node;
|
||||
|
||||
@@ -52,33 +47,23 @@ pub trait TokenRule {
|
||||
}
|
||||
|
||||
pub fn run_rules(file: &ast::ParsedFile) -> Vec<Diagnostic> {
|
||||
let node_diagnostics = file.nodes.iter().flat_map(|node| {
|
||||
[
|
||||
run_node_rule::<DeprecatedToPath>(node),
|
||||
run_node_rule::<EmptyInherit>(node),
|
||||
run_node_rule::<EmptyLetIn>(node),
|
||||
]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
let node_diagnostics = file.nodes.iter().flat_map(|_| std::iter::empty());
|
||||
let token_diagnostics = file
|
||||
.tokens
|
||||
.iter()
|
||||
.flat_map(|token| [run_token_rule::<UnquotedUri>(token)])
|
||||
.flatten();
|
||||
|
||||
node_diagnostics
|
||||
.chain(token_diagnostics)
|
||||
.map(|finding| Diagnostic {
|
||||
file_id: file.file_id,
|
||||
finding,
|
||||
})
|
||||
});
|
||||
|
||||
let token_diagnostics = file.tokens.iter().flat_map(|token| {
|
||||
[run_token_rule::<UnquotedUri>(token)]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.map(|finding| Diagnostic {
|
||||
file_id: file.file_id,
|
||||
finding,
|
||||
})
|
||||
});
|
||||
|
||||
node_diagnostics.chain(token_diagnostics).collect()
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[expect(dead_code, reason = "retained for planned node rules")]
|
||||
fn run_node_rule<R>(node: &ast::Node) -> Option<Finding>
|
||||
where
|
||||
R: NodeRule,
|
||||
|
||||
Reference in New Issue
Block a user