Skip to main content

slopguard_core/
finding.rs

1use std::path::PathBuf;
2
3use serde::Serialize;
4
5use crate::rule::{Category, RuleId, Severity};
6
7/// A single finding from scanning a source file.
8#[derive(Debug, Clone, Serialize)]
9pub struct Finding {
10    pub rule_id: RuleId,
11    pub severity: Severity,
12    pub category: Category,
13    pub message: String,
14    #[serde(skip_serializing_if = "Option::is_none")]
15    pub note: Option<String>,
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub fix: Option<String>,
18    pub file: PathBuf,
19    pub line: usize,
20    pub column: usize,
21    pub end_line: usize,
22    pub end_column: usize,
23    pub matched_text: String,
24}
25
26/// Aggregate statistics from a scan run.
27#[derive(Debug, Clone, Serialize)]
28pub struct ScanStats {
29    pub errors: usize,
30    pub warnings: usize,
31    pub total: usize,
32    pub files_scanned: usize,
33}
34
35/// The result of scanning one or more paths.
36#[derive(Debug, Clone, Serialize)]
37pub struct ScanResult {
38    pub findings: Vec<Finding>,
39    pub stats: ScanStats,
40}