ass_core/analysis/linting/
config.rs1use super::IssueSeverity;
7use alloc::vec::Vec;
8
9#[derive(Debug, Clone)]
11pub struct LintConfig {
12 pub min_severity: IssueSeverity,
14 pub max_issues: usize,
16 pub strict_mode: bool,
18 pub enabled_rules: Vec<&'static str>,
20 pub disabled_rules: Vec<&'static str>,
22}
23
24impl Default for LintConfig {
25 fn default() -> Self {
26 Self {
27 min_severity: IssueSeverity::Info,
28 max_issues: 0, strict_mode: false,
30 enabled_rules: Vec::new(),
31 disabled_rules: Vec::new(),
32 }
33 }
34}
35
36impl LintConfig {
37 #[must_use]
39 pub const fn with_min_severity(mut self, severity: IssueSeverity) -> Self {
40 self.min_severity = severity;
41 self
42 }
43
44 #[must_use]
46 pub const fn with_max_issues(mut self, max: usize) -> Self {
47 self.max_issues = max;
48 self
49 }
50
51 #[must_use]
53 pub const fn with_strict_compliance(mut self, enabled: bool) -> Self {
54 self.strict_mode = enabled;
55 self
56 }
57
58 #[must_use]
60 pub fn is_rule_enabled(&self, rule_id: &str) -> bool {
61 if self.disabled_rules.contains(&rule_id) {
62 return false;
63 }
64 self.enabled_rules.is_empty() || self.enabled_rules.contains(&rule_id)
65 }
66
67 #[must_use]
69 pub fn should_report_severity(&self, severity: IssueSeverity) -> bool {
70 severity >= self.min_severity
71 }
72}