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 lint error reported by a plugin.
Create errors using LintError::error() / LintError::warning() directly,
or more conveniently via ErrorBuilder (obtained from PluginSpec::error_builder()):
use nginx_lint_plugin::prelude::*;
let spec = PluginSpec::new("my-rule", "security", "Check something");
let err = spec.error_builder();
// Warning at a specific line/column
let warning = err.warning("message", 10, 5);
assert_eq!(warning.line, Some(10));
// Warning at a directive's location (most common pattern)
let config = nginx_lint_plugin::parse_string("autoindex on;").unwrap();
let directive = config.all_directives().next().unwrap();
let error = err.warning_at("use 'off'", directive)
.with_fix(directive.replace_with("autoindex off;"));
assert_eq!(error.fixes.len(), 1);Fields§
§rule: String§category: String§message: String§severity: Severity§line: Option<usize>§column: Option<usize>§fixes: Vec<Fix>Implementations§
Source§impl LintError
impl LintError
Sourcepub fn error(
rule: &str,
category: &str,
message: &str,
line: usize,
column: usize,
) -> Self
pub fn error( rule: &str, category: &str, message: &str, line: usize, column: usize, ) -> Self
Create a new error with Error severity
Sourcepub fn warning(
rule: &str,
category: &str,
message: &str,
line: usize,
column: usize,
) -> Self
pub fn warning( rule: &str, category: &str, message: &str, line: usize, column: usize, ) -> Self
Create a new error with Warning severity
Sourcepub fn with_fixes(self, fixes: Vec<Fix>) -> Self
pub fn with_fixes(self, fixes: Vec<Fix>) -> Self
Attach multiple fixes to this error
Trait Implementations§
Source§impl<'de> Deserialize<'de> for LintError
impl<'de> Deserialize<'de> for LintError
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for LintError
impl RefUnwindSafe for LintError
impl Send for LintError
impl Sync for LintError
impl Unpin for LintError
impl UnsafeUnpin for LintError
impl UnwindSafe for LintError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more