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
| Method | Purpose |
|---|---|
name | Unique rule identifier (e.g. "server-tokens-enabled") |
category | Category for grouping (e.g. "security") |
description | One-line human-readable summary |
check | Run the rule and return diagnostics |
Required Methods§
Sourcefn description(&self) -> &'static str
fn description(&self) -> &'static str
One-line human-readable description of what this rule checks.
Provided Methods§
Sourcefn check_with_serialized_config(
&self,
config: &Config,
path: &Path,
_serialized_config: &str,
) -> Vec<LintError>
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().
Sourcefn bad_example(&self) -> Option<&str>
fn bad_example(&self) -> Option<&str>
Get example of bad configuration
Sourcefn good_example(&self) -> Option<&str>
fn good_example(&self) -> Option<&str>
Get example of good configuration
Sourcefn references(&self) -> Option<Vec<String>>
fn references(&self) -> Option<Vec<String>>
Get reference URLs