1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct Diagnostic {
7 pub severity: Severity,
8 pub code: String,
9 pub message: String,
10 pub path: Option<String>,
11 pub span: Option<Span>,
12 pub repair: Option<Repair>,
13 pub confidence: f64,
15 #[serde(default)]
19 pub file: Option<String>,
20}
21
22#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
23#[serde(rename_all = "lowercase")]
24pub enum Severity {
25 Error,
26 Warning,
27 Info,
28 Hint,
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
32pub struct Span {
33 pub line: u32,
34 pub column: u32,
35 pub end_line: u32,
36 pub end_column: u32,
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
40pub struct Repair {
41 pub original: String,
42 pub suggested: String,
43 pub kind: RepairKind,
44 pub safe: bool,
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
49#[serde(rename_all = "snake_case")]
50pub enum RepairKind {
51 InsertQuote,
52 RemoveTrailingComma,
53 KeyTypo,
54 TypeCoercion,
55 MissingDefault,
56 UnitNormalization,
57 Other(String),
58}
59
60pub mod thresholds {
62 pub const AUTO_APPLY: f64 = 0.95;
63 pub const HIGH: f64 = 0.85;
64 pub const MEDIUM: f64 = 0.70;
65 }