1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
mod homogenous_assignment;
mod redundant_nesting;
mod unary_series;
use homogenous_assignment::*;
use redundant_nesting::*;
use unary_series::*;
use super::{DiagnosticRecord, LintRule};
use crate::diagnostics::Diagnostic;
use crate::grammar::StmtList;
macro_rules! define_stmt_lints {
($($linter:ident,)*) => {
pub enum StmtLintRule {
$($linter),*
}
impl StmtLintRule {
pub fn lint(&self, stmt_list: &StmtList, source: &str) -> Vec<Diagnostic> {
match self {
$(Self::$linter => $linter::lint(stmt_list, source)),*
}
}
pub fn all_explanations() -> Vec<(&'static str, &'static str)> {
let mut vec = Vec::new();
$(vec.push(($linter::CODE, $linter::EXPLANATION));)*
vec
}
}
};
}
define_stmt_lints! {
UnarySeriesLinter,
RedundantNestingLinter,
HomogenousAssignmentLinter,
}