Skip to main content

LintConfig

Struct LintConfig 

Source
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

Source

pub fn builder() -> LintConfigBuilder

Create a new LintConfigBuilder for constructing a LintConfig.

Source§

impl LintConfig

Source

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:

  1. It’s not in the disabled_rules list
  2. It’s applicable to the current target tool
  3. Its category is enabled

This delegates to DefaultRuleFilter which encapsulates the filtering logic.

Source

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

Source

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

Source

pub fn load<P: AsRef<Path>>(path: P) -> Result<Self>

Load config from file

Source

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.

Source

pub fn root_dir(&self) -> Option<&PathBuf>

Get the runtime validation root directory, if set.

Source

pub fn get_root_dir(&self) -> Option<&PathBuf>

Alias for root_dir() for consistency with other accessors.

Source

pub fn set_root_dir(&mut self, root_dir: PathBuf)

Set the runtime validation root directory (not persisted).

Source

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.

Source

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.

Source

pub fn get_import_cache( &self, ) -> Option<&Arc<RwLock<HashMap<PathBuf, Vec<Import>>>>>

Alias for import_cache() for consistency with other accessors.

Source

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.

Source

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.

Source

pub fn severity(&self) -> SeverityLevel

Get the severity level threshold.

Source

pub fn rules(&self) -> &RuleConfig

Get the rules configuration.

Source

pub fn exclude(&self) -> &[String]

Get the exclude patterns.

Source

pub fn target(&self) -> TargetTool

Get the target tool.

Source

pub fn tools(&self) -> &[String]

Get the tools list.

Source

pub fn tool_versions(&self) -> &ToolVersions

Get the tool versions configuration.

Source

pub fn spec_revisions(&self) -> &SpecRevisions

Get the spec revisions configuration.

Source

pub fn files_config(&self) -> &FilesConfig

Get the files configuration.

Source

pub fn locale(&self) -> Option<&str>

Get the locale, if set.

Source

pub fn max_files_to_validate(&self) -> Option<usize>

Get the maximum number of files to validate.

Source

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().

Source

pub fn set_severity(&mut self, severity: SeverityLevel)

Set the severity level threshold.

Source

pub fn set_target(&mut self, target: TargetTool)

Set the target tool.

Source

pub fn set_tools(&mut self, tools: Vec<String>)

Set the tools list.

Source

pub fn tools_mut(&mut self) -> &mut Vec<String>

Get a mutable reference to the tools list.

Source

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.

Source

pub fn set_locale(&mut self, locale: Option<String>)

Set the locale.

Source

pub fn set_max_files_to_validate(&mut self, max: Option<usize>)

Set the maximum number of files to validate.

Source

pub fn set_mcp_protocol_version(&mut self, version: Option<String>)

Set the MCP protocol version (deprecated field).

Source

pub fn rules_mut(&mut self) -> &mut RuleConfig

Get a mutable reference to the rules configuration.

Source

pub fn tool_versions_mut(&mut self) -> &mut ToolVersions

Get a mutable reference to the tool versions configuration.

Source

pub fn spec_revisions_mut(&mut self) -> &mut SpecRevisions

Get a mutable reference to the spec revisions configuration.

Source

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.

Source

pub fn get_mcp_protocol_version(&self) -> &str

Get the expected MCP protocol version

Priority: spec_revisions.mcp_protocol > mcp_protocol_version > default

Source

pub fn is_mcp_revision_pinned(&self) -> bool

Check if MCP protocol revision is explicitly pinned

Source

pub fn is_claude_code_version_pinned(&self) -> bool

Check if Claude Code version is explicitly pinned

Source

pub fn get_claude_code_version(&self) -> Option<&str>

Get the pinned Claude Code version, if any

Trait Implementations§

Source§

impl Clone for LintConfig

Source§

fn clone(&self) -> LintConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LintConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LintConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for LintConfig

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for LintConfig

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl Serialize for LintConfig

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,