pub struct Violation {
pub code: ViolationCode,
pub severity: Severity,
pub rule: String,
pub path: String,
pub line: Option<usize>,
pub symbol: String,
pub message: String,
pub why: String,
pub remediation: String,
}Expand description
One finding: what, where, why, and what to do.
Fields§
§code: ViolationCodeThe stable code.
severity: SeverityHow bad it is.
rule: StringThe canonical id of the rule that requires this.
path: StringWhere it is, repository-relative; empty when the finding is not about a file.
line: Option<usize>The line, 1-based; None when the finding is not about a line.
symbol: StringThe item’s full path, or the command, or the capability id: what the finding is about.
message: StringOne sentence, specific to this occurrence.
why: StringWhy it matters, from the code.
remediation: StringWhat to do, from the code.
Implementations§
Source§impl Violation
impl Violation
Sourcepub fn new(
code: ViolationCode,
symbol: impl Into<String>,
path: impl Into<String>,
line: Option<usize>,
message: impl Into<String>,
) -> Self
pub fn new( code: ViolationCode, symbol: impl Into<String>, path: impl Into<String>, line: Option<usize>, message: impl Into<String>, ) -> Self
A finding about an item at a place.
The why and the remediation come from the code rather than from the caller, so
that two findings of one kind cannot explain themselves differently.
use majordomus_cli::quality::{Violation, ViolationCode};
let v = Violation::new(
ViolationCode::RustModuleMissingExample,
"majordomus_cli::graph",
"apps/majordomus-cli/src/graph.rs",
Some(1),
"the module header carries no executable example",
);
assert_eq!(v.rule, "project.rust-public-api-quality@1");
assert!(v.remediation.contains("//!"));Sourcepub fn line_summary(&self) -> String
pub fn line_summary(&self) -> String
The finding as one line, the way the terminal and a CI annotation show it.
use majordomus_cli::quality::{Violation, ViolationCode};
let v = Violation::new(
ViolationCode::RustPublicMissingExample,
"majordomus_cli::graph::build",
"apps/majordomus-cli/src/graph.rs",
Some(42),
"carries behaviour and no executable example",
);
assert_eq!(
v.line_summary(),
"apps/majordomus-cli/src/graph.rs:42: RUST_PUBLIC_MISSING_EXAMPLE majordomus_cli::graph::build — carries behaviour and no executable example"
);Trait Implementations§
Source§impl<'de> Deserialize<'de> for Violation
impl<'de> Deserialize<'de> for Violation
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
impl Eq for Violation
Source§impl JsonSchema for Violation
impl JsonSchema for Violation
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreimpl StructuralPartialEq for Violation
Auto Trait Implementations§
impl Freeze for Violation
impl RefUnwindSafe for Violation
impl Send for Violation
impl Sync for Violation
impl Unpin for Violation
impl UnsafeUnpin for Violation
impl UnwindSafe for Violation
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.