use serde::{Deserialize, Serialize};
use std::path::PathBuf;
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ViolationType {
UnderscoreBandaid,
WrongEdition,
FileTooLarge,
FunctionTooLarge,
LineTooLong,
UnwrapInProduction,
MissingDocs,
MissingDependencies,
OldRustVersion,
LockedSetting,
MissingModuleDoc,
MissingDocConfig,
HardcodedVersion,
MissingChangelogEntry,
InvalidChangelogFormat,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum Severity {
Error,
Warning,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Violation {
pub violation_type: ViolationType,
pub file: PathBuf,
pub line: usize,
pub message: String,
pub severity: Severity,
}
impl Violation {
pub fn new(
violation_type: ViolationType,
file: PathBuf,
line: usize,
message: String,
severity: Severity,
) -> Self {
Self {
violation_type,
file,
line,
message,
severity,
}
}
pub fn is_locked_setting(&self) -> bool {
matches!(
self.violation_type,
ViolationType::WrongEdition
| ViolationType::OldRustVersion
| ViolationType::LockedSetting
)
}
}