LintRule

Trait LintRule 

Source
pub trait LintRule: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn category(&self) -> &'static str;
    fn description(&self) -> &'static str;
    fn check(&self, config: &Config, path: &Path) -> Vec<LintError>;

    // Provided methods
    fn check_with_serialized_config(
        &self,
        config: &Config,
        path: &Path,
        _serialized_config: &str,
    ) -> Vec<LintError> { ... }
    fn why(&self) -> Option<&str> { ... }
    fn bad_example(&self) -> Option<&str> { ... }
    fn good_example(&self) -> Option<&str> { ... }
    fn references(&self) -> Option<Vec<String>> { ... }
    fn severity(&self) -> Option<&str> { ... }
}
Expand description

A lint rule that can be checked against a parsed nginx configuration.

Every rule — whether implemented as a native Rust struct or as a WASM plugin — implements this trait. The four required methods supply metadata and the check logic; the optional methods provide documentation and plugin-specific overrides.

§Required methods

MethodPurpose
nameUnique rule identifier (e.g. "server-tokens-enabled")
categoryCategory for grouping (e.g. "security")
descriptionOne-line human-readable summary
checkRun the rule and return diagnostics

Required Methods§

Source

fn name(&self) -> &'static str

Unique identifier for this rule (e.g. "server-tokens-enabled").

Source

fn category(&self) -> &'static str

Category this rule belongs to (e.g. "security", "style").

Source

fn description(&self) -> &'static str

One-line human-readable description of what this rule checks.

Source

fn check(&self, config: &Config, path: &Path) -> Vec<LintError>

Run the rule against config (parsed from path) and return diagnostics.

Provided Methods§

Source

fn check_with_serialized_config( &self, config: &Config, path: &Path, _serialized_config: &str, ) -> Vec<LintError>

Check with pre-serialized config JSON (optimization for WASM plugins)

This method allows passing a pre-serialized config JSON to avoid repeated serialization when running multiple plugins. Default implementation ignores the serialized config and calls check().

Source

fn why(&self) -> Option<&str>

Get detailed explanation of why this rule exists

Source

fn bad_example(&self) -> Option<&str>

Get example of bad configuration

Source

fn good_example(&self) -> Option<&str>

Get example of good configuration

Source

fn references(&self) -> Option<Vec<String>>

Get reference URLs

Source

fn severity(&self) -> Option<&str>

Get severity level (for plugins)

Implementors§