pub struct LintError {
pub rule: String,
pub category: String,
pub message: String,
pub severity: Severity,
pub line: Option<usize>,
pub column: Option<usize>,
pub fixes: Vec<Fix>,
}Expand description
A single lint diagnostic produced by a rule.
Every LintRule::check call returns a Vec<LintError>. Each error
carries the rule name, category, a human-readable message, severity, an
optional source location, and zero or more Fix proposals.
§Building errors
use nginx_lint_common::linter::{LintError, Severity, Fix};
let error = LintError::new("my-rule", "style", "trailing whitespace", Severity::Warning)
.with_location(10, 1)
.with_fix(Fix::replace(10, "value ", "value"));Fields§
§rule: StringRule identifier (e.g. "server-tokens-enabled").
category: StringCategory the rule belongs to (e.g. "security", "style").
message: StringHuman-readable description of the problem.
severity: SeverityWhether this is an error or a warning.
line: Option<usize>1-indexed line number where the problem was detected.
column: Option<usize>1-indexed column number where the problem was detected.
fixes: Vec<Fix>Auto-fix proposals that can resolve this diagnostic.
Implementations§
Source§impl LintError
impl LintError
Sourcepub fn new(
rule: &str,
category: &str,
message: &str,
severity: Severity,
) -> Self
pub fn new( rule: &str, category: &str, message: &str, severity: Severity, ) -> Self
Create a new lint error without a source location.
Use with_location to attach line/column info
and with_fix to attach auto-fix proposals.
Sourcepub fn with_location(self, line: usize, column: usize) -> Self
pub fn with_location(self, line: usize, column: usize) -> Self
Attach a source location (1-indexed line and column) to this error.
Sourcepub fn with_fixes(self, fixes: Vec<Fix>) -> Self
pub fn with_fixes(self, fixes: Vec<Fix>) -> Self
Append multiple Fix proposals to this error.