pub trait LintRule: Send + Sync {
Show 16 methods
// 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 wants_shared_config(&self) -> bool { ... }
fn check_shared(&self, config: &Arc<Config>, path: &Path) -> Vec<LintError> { ... }
fn wants_content(&self) -> bool { ... }
fn check_with_content(
&self,
config: &Config,
path: &Path,
_content: &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> { ... }
fn min_nginx_version(&self) -> Option<&str> { ... }
fn max_nginx_version(&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>
👎Deprecated since 0.16.0: no longer called by the linter; the serialized config was only used by legacy core-module plugins. Implement check() or check_shared() instead.
fn check_with_serialized_config( &self, config: &Config, path: &Path, _serialized_config: &str, ) -> Vec<LintError>
no longer called by the linter; the serialized config was only used by legacy core-module plugins. Implement check() or check_shared() instead.
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().
Whether this rule wants the config as a shared Arc handle.
Rules that hand the config to another owner (e.g. WASM plugin rules,
which store it in the sandbox’s resource table) should return true
so the linter shares one Arc<Config> across all such rules instead
of each rule deep-cloning the AST per check.
Run the rule with a shared config handle.
The linter calls this instead of check when
wants_shared_config returns true.
Default implementation borrows the config and calls check().
Sourcefn wants_content(&self) -> bool
fn wants_content(&self) -> bool
Whether this rule wants the raw file content directly.
Rules that need to re-derive diagnostics from the source text itself
(rather than the parsed Config) should return true so the linter
hands them the content it already has in memory, instead of each rule
independently re-reading the file from disk and re-parsing it.
Note: this does not compose with wants_shared_config —
the default check_with_content delegates to
check, not check_shared. No current
rule needs both; a future one that does would need a custom override.
Sourcefn check_with_content(
&self,
config: &Config,
path: &Path,
_content: &str,
) -> Vec<LintError>
fn check_with_content( &self, config: &Config, path: &Path, _content: &str, ) -> Vec<LintError>
Run the rule with the raw file content already available.
The linter calls this instead of check/check_shared
when wants_content returns true and content is available.
Default implementation ignores content 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
Sourcefn min_nginx_version(&self) -> Option<&str>
fn min_nginx_version(&self) -> Option<&str>
Minimum nginx version this rule applies to (inclusive).
None means the rule applies regardless of how old the nginx version is.
Used by the linter’s version-based rule filter to decide whether to
run this rule against a config whose
target_nginx_version
is set.
Sourcefn max_nginx_version(&self) -> Option<&str>
fn max_nginx_version(&self) -> Option<&str>
Maximum nginx version this rule applies to (inclusive).
None means the rule applies regardless of how new the nginx version is.