Skip to main content

ass_core/analysis/linting/
config.rs

1//! Configuration for linting behavior.
2//!
3//! Defines [`LintConfig`], controlling which rules run, the minimum
4//! severity reported, and the maximum number of issues collected.
5
6use super::IssueSeverity;
7use alloc::vec::Vec;
8
9/// Configuration for linting behavior.
10#[derive(Debug, Clone)]
11pub struct LintConfig {
12    /// Minimum severity level to report
13    pub min_severity: IssueSeverity,
14    /// Maximum number of issues to report (0 = unlimited)
15    pub max_issues: usize,
16    /// Enable strict compliance mode
17    pub strict_mode: bool,
18    /// Enabled rule IDs (empty = all enabled)
19    pub enabled_rules: Vec<&'static str>,
20    /// Disabled rule IDs
21    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, // Unlimited
29            strict_mode: false,
30            enabled_rules: Vec::new(),
31            disabled_rules: Vec::new(),
32        }
33    }
34}
35
36impl LintConfig {
37    /// Set minimum severity level.
38    #[must_use]
39    pub const fn with_min_severity(mut self, severity: IssueSeverity) -> Self {
40        self.min_severity = severity;
41        self
42    }
43
44    /// Set maximum number of issues.
45    #[must_use]
46    pub const fn with_max_issues(mut self, max: usize) -> Self {
47        self.max_issues = max;
48        self
49    }
50
51    /// Enable strict compliance checking.
52    #[must_use]
53    pub const fn with_strict_compliance(mut self, enabled: bool) -> Self {
54        self.strict_mode = enabled;
55        self
56    }
57
58    /// Check if a rule is enabled.
59    #[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    /// Check if severity should be reported.
68    #[must_use]
69    pub fn should_report_severity(&self, severity: IssueSeverity) -> bool {
70        severity >= self.min_severity
71    }
72}