pub struct Finding {
pub check: &'static str,
pub file: String,
pub line: Option<usize>,
pub column: Option<usize>,
pub severity: Severity,
pub message: String,
}Expand description
A single problem, addressable.
Fields§
§check: &'static strThe check’s short name — ban-terms, not pre-commit-ban-terms. The
stage is not a property of the finding: the same content problem is the
same problem whichever hook noticed it, and an editor has no stages.
file: StringRepository-relative, as git spells it.
line: Option<usize>1-based, as every editor and terminal counts. None when the finding is
about the file as a whole.
column: Option<usize>1-based, counted in CHARACTERS rather than bytes — see line_col.
severity: Severity§message: StringOne line, no trailing period, safe to print. Anything derived from file
content must be sanitised by its producer before it gets here: this type
will happily print whatever it is given, and secrets in particular
must never put the matched text in it.
Implementations§
Source§impl Finding
impl Finding
pub fn new( check: &'static str, file: impl Into<String>, severity: Severity, message: impl Into<String>, ) -> Self
Sourcepub fn at_offset(self, content: &str, offset: usize) -> Self
pub fn at_offset(self, content: &str, offset: usize) -> Self
Place this finding at a byte offset within content.
Sourcepub fn at_line(self, line: usize) -> Self
pub fn at_line(self, line: usize) -> Self
Place it on a line whose column is not known or not meaningful.