pub struct PluginSpec {
pub name: String,
pub category: String,
pub description: String,
pub api_version: String,
pub severity: Option<String>,
pub why: Option<String>,
pub bad_example: Option<String>,
pub good_example: Option<String>,
pub references: Option<Vec<String>>,
pub min_nginx_version: Option<String>,
pub max_nginx_version: Option<String>,
}Expand description
Plugin metadata describing a lint rule.
Created via PluginSpec::new() and configured with builder methods.
§Example
use nginx_lint_plugin::PluginSpec;
let spec = PluginSpec::new("my-rule", "security", "Short description")
.with_severity("warning")
.with_why("Detailed explanation of why this rule exists.")
.with_bad_example("server {\n bad_directive on;\n}")
.with_good_example("server {\n bad_directive off;\n}")
.with_references(vec![
"https://nginx.org/en/docs/...".to_string(),
]);
assert_eq!(spec.name, "my-rule");
assert_eq!(spec.category, "security");
assert_eq!(spec.severity, Some("warning".to_string()));Fields§
§name: StringUnique name for the rule (e.g., “my-custom-rule”)
category: StringCategory (e.g., “security”, “style”, “best_practices”, “custom”)
description: StringHuman-readable description
api_version: StringAPI version the plugin uses for input/output format
severity: Option<String>Severity level (error, warning)
why: Option<String>Why this rule exists (detailed explanation)
bad_example: Option<String>Example of bad configuration
good_example: Option<String>Example of good configuration
references: Option<Vec<String>>References (URLs, documentation links)
min_nginx_version: Option<String>Minimum nginx version this rule applies to (inclusive, e.g. "0.6.27").
None means unbounded on the lower end.
max_nginx_version: Option<String>Maximum nginx version this rule applies to (inclusive, e.g. "1.30.0").
None means unbounded on the upper end.
Implementations§
Source§impl PluginSpec
impl PluginSpec
Sourcepub fn new(
name: impl Into<String>,
category: impl Into<String>,
description: impl Into<String>,
) -> Self
pub fn new( name: impl Into<String>, category: impl Into<String>, description: impl Into<String>, ) -> Self
Create a new PluginSpec with the current API version
Sourcepub fn with_severity(self, severity: impl Into<String>) -> Self
pub fn with_severity(self, severity: impl Into<String>) -> Self
Set the severity level
Sourcepub fn with_bad_example(self, example: impl Into<String>) -> Self
pub fn with_bad_example(self, example: impl Into<String>) -> Self
Set the bad example
Sourcepub fn with_good_example(self, example: impl Into<String>) -> Self
pub fn with_good_example(self, example: impl Into<String>) -> Self
Set the good example
Sourcepub fn with_references(self, refs: Vec<String>) -> Self
pub fn with_references(self, refs: Vec<String>) -> Self
Set references
Sourcepub fn with_min_version(self, version: impl Into<String>) -> Self
pub fn with_min_version(self, version: impl Into<String>) -> Self
Declare the lowest nginx version this rule applies to (inclusive).
Sourcepub fn with_max_version(self, version: impl Into<String>) -> Self
pub fn with_max_version(self, version: impl Into<String>) -> Self
Declare the highest nginx version this rule applies to (inclusive).
Sourcepub fn error_builder(&self) -> ErrorBuilder
pub fn error_builder(&self) -> ErrorBuilder
Create an error builder that uses this plugin’s name and category
This reduces boilerplate when creating errors in the check method.
§Example
use nginx_lint_plugin::{PluginSpec, Severity};
let spec = PluginSpec::new("my-rule", "security", "Check something");
let err = spec.error_builder();
// Instead of:
// LintError::warning("my-rule", "security", "message", 10, 5)
// Use:
let warning = err.warning("message", 10, 5);
assert_eq!(warning.rule, "my-rule");
assert_eq!(warning.category, "security");
assert_eq!(warning.severity, Severity::Warning);Trait Implementations§
Source§impl Clone for PluginSpec
impl Clone for PluginSpec
Source§fn clone(&self) -> PluginSpec
fn clone(&self) -> PluginSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more