pub struct LintConfig { /* private fields */ }Expand description
Configuration for the linter
§Cheap Cloning via Arc<ConfigData>
All serializable fields are stored in a shared Arc<ConfigData>.
Cloning a LintConfig bumps the Arc refcount and shallow-copies the
lightweight RuntimeContext - no heap-allocated Vec<String> or nested
structs are deep-copied. Setters use Arc::make_mut for copy-on-write
semantics, so mutations only allocate when the Arc is shared.
Implementations§
Source§impl LintConfig
impl LintConfig
Sourcepub fn builder() -> LintConfigBuilder
pub fn builder() -> LintConfigBuilder
Create a new LintConfigBuilder for constructing a LintConfig.
Source§impl LintConfig
impl LintConfig
Sourcepub fn is_rule_enabled(&self, rule_id: &str) -> bool
pub fn is_rule_enabled(&self, rule_id: &str) -> bool
Check if a specific rule is enabled based on config
A rule is enabled if:
- It’s not in the disabled_rules list
- It’s applicable to the current target tool
- Its category is enabled
This delegates to DefaultRuleFilter which encapsulates the filtering logic.
Sourcepub fn is_tool_alias(user_tool: &str, canonical_tool: &str) -> bool
pub fn is_tool_alias(user_tool: &str, canonical_tool: &str) -> bool
Check if a user-provided tool name is a backward-compatible alias for the canonical tool name from rules.json.
Currently only “github-copilot” has an alias (“copilot”). This exists for backward compatibility: early versions of agnix used the shorter “copilot” name in configs, and we need to continue supporting that for existing users. The canonical names in rules.json use the full “github-copilot” to match the official tool name from GitHub’s documentation.
Note: This function does NOT treat canonical names as aliases of themselves. For example, “github-copilot” is NOT an alias for “github-copilot” - that’s handled by the direct eq_ignore_ascii_case comparison in is_rule_for_tools().
Source§impl LintConfig
impl LintConfig
Sourcepub fn validate(&self) -> Vec<ConfigWarning>
pub fn validate(&self) -> Vec<ConfigWarning>
Validate the configuration and return any warnings.
This performs semantic validation beyond what TOML parsing can check:
- Validates that disabled_rules match known rule ID patterns
- Validates that tools array contains known tool names
- Warns on deprecated fields
Source§impl LintConfig
impl LintConfig
Sourcepub fn load_or_default(path: Option<&PathBuf>) -> (Self, Option<String>)
pub fn load_or_default(path: Option<&PathBuf>) -> (Self, Option<String>)
Load config or use default, returning any parse warning
Returns a tuple of (config, optional_warning). If a config path is provided but the file cannot be loaded or parsed, returns the default config with a warning message describing the error. This prevents silent fallback to defaults on config typos or missing/unreadable config files.
Sourcepub fn get_root_dir(&self) -> Option<&PathBuf>
pub fn get_root_dir(&self) -> Option<&PathBuf>
Alias for root_dir() for consistency with other accessors.
Sourcepub fn set_root_dir(&mut self, root_dir: PathBuf)
pub fn set_root_dir(&mut self, root_dir: PathBuf)
Set the runtime validation root directory (not persisted).
Sourcepub fn set_import_cache(
&mut self,
cache: Arc<RwLock<HashMap<PathBuf, Vec<Import>>>>,
)
pub fn set_import_cache( &mut self, cache: Arc<RwLock<HashMap<PathBuf, Vec<Import>>>>, )
Set the shared import cache for project-level validation (not persisted).
When set, the ImportsValidator will use this cache to share parsed import data across files, improving performance by avoiding redundant parsing during import chain traversal.
Sourcepub fn import_cache(
&self,
) -> Option<&Arc<RwLock<HashMap<PathBuf, Vec<Import>>>>>
pub fn import_cache( &self, ) -> Option<&Arc<RwLock<HashMap<PathBuf, Vec<Import>>>>>
Get the shared import cache, if one has been set.
Returns None for single-file validation or when the cache hasn’t
been initialized. Returns Some(&ImportCache) during project-level
validation where import results are shared across files.
Sourcepub fn get_import_cache(
&self,
) -> Option<&Arc<RwLock<HashMap<PathBuf, Vec<Import>>>>>
pub fn get_import_cache( &self, ) -> Option<&Arc<RwLock<HashMap<PathBuf, Vec<Import>>>>>
Alias for import_cache() for consistency with other accessors.
Sourcepub fn fs(&self) -> &Arc<dyn FileSystem>
pub fn fs(&self) -> &Arc<dyn FileSystem>
Get the file system abstraction.
Validators should use this for file system operations instead of
directly calling std::fs functions. This enables unit testing
with MockFileSystem.
Sourcepub fn set_fs(&mut self, fs: Arc<dyn FileSystem>)
pub fn set_fs(&mut self, fs: Arc<dyn FileSystem>)
Set the file system abstraction (not persisted).
This is primarily used for testing with MockFileSystem.
§Important
This should only be called during configuration setup, before validation begins. Changing the filesystem during validation may cause inconsistent results if validators have already cached file state.
Sourcepub fn severity(&self) -> SeverityLevel
pub fn severity(&self) -> SeverityLevel
Get the severity level threshold.
Sourcepub fn rules(&self) -> &RuleConfig
pub fn rules(&self) -> &RuleConfig
Get the rules configuration.
Sourcepub fn target(&self) -> TargetTool
pub fn target(&self) -> TargetTool
Get the target tool.
Sourcepub fn tool_versions(&self) -> &ToolVersions
pub fn tool_versions(&self) -> &ToolVersions
Get the tool versions configuration.
Sourcepub fn spec_revisions(&self) -> &SpecRevisions
pub fn spec_revisions(&self) -> &SpecRevisions
Get the spec revisions configuration.
Sourcepub fn files_config(&self) -> &FilesConfig
pub fn files_config(&self) -> &FilesConfig
Get the files configuration.
Sourcepub fn max_files_to_validate(&self) -> Option<usize>
pub fn max_files_to_validate(&self) -> Option<usize>
Get the maximum number of files to validate.
Sourcepub fn mcp_protocol_version_raw(&self) -> Option<&str>
pub fn mcp_protocol_version_raw(&self) -> Option<&str>
Get the raw mcp_protocol_version field value (without fallback logic).
For the resolved version with fallback, use get_mcp_protocol_version().
Sourcepub fn set_severity(&mut self, severity: SeverityLevel)
pub fn set_severity(&mut self, severity: SeverityLevel)
Set the severity level threshold.
Sourcepub fn set_target(&mut self, target: TargetTool)
pub fn set_target(&mut self, target: TargetTool)
Set the target tool.
Sourcepub fn set_exclude(&mut self, exclude: Vec<String>)
pub fn set_exclude(&mut self, exclude: Vec<String>)
Set the exclude patterns.
Note: This does not validate the patterns. Call validate()
after using this if validation is needed.
Sourcepub fn set_locale(&mut self, locale: Option<String>)
pub fn set_locale(&mut self, locale: Option<String>)
Set the locale.
Sourcepub fn set_max_files_to_validate(&mut self, max: Option<usize>)
pub fn set_max_files_to_validate(&mut self, max: Option<usize>)
Set the maximum number of files to validate.
Sourcepub fn set_mcp_protocol_version(&mut self, version: Option<String>)
pub fn set_mcp_protocol_version(&mut self, version: Option<String>)
Set the MCP protocol version (deprecated field).
Sourcepub fn rules_mut(&mut self) -> &mut RuleConfig
pub fn rules_mut(&mut self) -> &mut RuleConfig
Get a mutable reference to the rules configuration.
Sourcepub fn tool_versions_mut(&mut self) -> &mut ToolVersions
pub fn tool_versions_mut(&mut self) -> &mut ToolVersions
Get a mutable reference to the tool versions configuration.
Sourcepub fn spec_revisions_mut(&mut self) -> &mut SpecRevisions
pub fn spec_revisions_mut(&mut self) -> &mut SpecRevisions
Get a mutable reference to the spec revisions configuration.
Sourcepub fn files_mut(&mut self) -> &mut FilesConfig
pub fn files_mut(&mut self) -> &mut FilesConfig
Get a mutable reference to the files configuration.
Note: Mutations bypass builder validation. Call validate()
after modifying if validation is needed.
Sourcepub fn get_mcp_protocol_version(&self) -> &str
pub fn get_mcp_protocol_version(&self) -> &str
Get the expected MCP protocol version
Priority: spec_revisions.mcp_protocol > mcp_protocol_version > default
Sourcepub fn is_mcp_revision_pinned(&self) -> bool
pub fn is_mcp_revision_pinned(&self) -> bool
Check if MCP protocol revision is explicitly pinned
Sourcepub fn is_claude_code_version_pinned(&self) -> bool
pub fn is_claude_code_version_pinned(&self) -> bool
Check if Claude Code version is explicitly pinned
Sourcepub fn get_claude_code_version(&self) -> Option<&str>
pub fn get_claude_code_version(&self) -> Option<&str>
Get the pinned Claude Code version, if any
Trait Implementations§
Source§impl Clone for LintConfig
impl Clone for LintConfig
Source§fn clone(&self) -> LintConfig
fn clone(&self) -> LintConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LintConfig
impl Debug for LintConfig
Source§impl Default for LintConfig
impl Default for LintConfig
Source§impl<'de> Deserialize<'de> for LintConfig
impl<'de> Deserialize<'de> for LintConfig
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl JsonSchema for LintConfig
impl JsonSchema for LintConfig
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreAuto Trait Implementations§
impl Freeze for LintConfig
impl !RefUnwindSafe for LintConfig
impl Send for LintConfig
impl Sync for LintConfig
impl Unpin for LintConfig
impl UnsafeUnpin for LintConfig
impl !UnwindSafe for LintConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more