Skip to main content

FileRule

Trait FileRule 

Source
pub trait FileRule: Send + Sync {
    type Finding: Serialize + DeserializeOwned + Send;

    // Required methods
    fn engine_name(&self) -> &str;
    fn config_hash(&self) -> String;
    fn check_file(&self, path: &Path, root: &Path) -> Vec<Self::Finding>;
    fn to_diagnostics(
        &self,
        findings: Vec<(PathBuf, Vec<Self::Finding>)>,
        root: &Path,
        files_checked: usize,
    ) -> DiagnosticsReport;
}
Expand description

Trait for native rules that check individual files.

Implementing this trait gives automatic SQLite caching and parallel execution. Rule authors implement check_file() and to_diagnostics() — the framework handles the rest.

Required Associated Types§

Source

type Finding: Serialize + DeserializeOwned + Send

Serializable per-file finding type.

Required Methods§

Source

fn engine_name(&self) -> &str

Unique engine name for cache keying (e.g. “long-function”, “high-complexity”).

Source

fn config_hash(&self) -> String

Config hash for cache invalidation (e.g. threshold.to_string()).

Source

fn check_file(&self, path: &Path, root: &Path) -> Vec<Self::Finding>

Check a single file. Returns findings for that file. path is absolute, root is the project root for computing relative paths.

Source

fn to_diagnostics( &self, findings: Vec<(PathBuf, Vec<Self::Finding>)>, root: &Path, files_checked: usize, ) -> DiagnosticsReport

Convert collected findings into a DiagnosticsReport. findings maps file path to that file’s findings. files_checked is the total number of files examined (cached + fresh).

Implementors§