1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
4#[serde(rename_all = "snake_case")]
5pub enum FindingTier {
6 Slop,
7 KindaSlop,
8 Clean,
9}
10
11impl FindingTier {
12 pub fn label(self) -> &'static str {
13 match self {
14 FindingTier::Slop => "Slop",
15 FindingTier::KindaSlop => "Kinda Slop",
16 FindingTier::Clean => "Clean",
17 }
18 }
19
20 pub fn json_label(self) -> &'static str {
21 match self {
22 FindingTier::Slop => "slop",
23 FindingTier::KindaSlop => "kinda_slop",
24 FindingTier::Clean => "clean",
25 }
26 }
27}
28
29#[derive(Debug, Clone, Serialize, Deserialize)]
30pub struct Reference {
31 pub file_path: String,
32 pub line: usize,
33 pub snippet: String,
34}
35
36#[derive(Debug, Clone, Serialize, Deserialize)]
37pub struct MethodRecord {
38 pub name: String,
39 pub file_path: String,
40 pub source: String,
41 pub loc: usize,
42 pub param_count: usize,
43 pub start_line: usize,
44 pub end_line: usize,
45 pub is_exported: bool,
46 pub language: String,
47 pub nesting_depth: usize,
48 pub references: Vec<Reference>,
49 pub real_ref_count: usize,
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
53pub struct FileRecord {
54 pub file_path: String,
55 pub source: String,
56 pub language: String,
57 pub methods: Vec<MethodRecord>,
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
61pub enum SymbolKind {
62 Function,
63 Method,
64 Class,
65 Variable,
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
69pub struct SymbolDefinition {
70 pub id: usize,
71 pub name: String,
72 pub kind: SymbolKind,
73 pub start_line: usize,
74 pub end_line: usize,
75 pub is_exported: bool,
76 pub owner_type: Option<String>,
77}
78
79#[derive(Debug, Clone, Serialize, Deserialize)]
80pub struct ImportRecord {
81 pub local_name: String,
82 pub source_module: String,
83 pub imported_name: String,
84}
85
86#[derive(Debug, Clone, Serialize, Deserialize)]
87pub struct ExportRecord {
88 pub exported_name: String,
89 pub local_symbol_name: String,
90 pub source_module: Option<String>,
91 pub source_symbol_name: Option<String>,
92}
93
94#[derive(Debug, Clone, Serialize, Deserialize)]
95pub struct SymbolReference {
96 pub name: String,
97 pub line: usize,
98 pub snippet: String,
99 pub resolved_symbol: Option<ResolvedSymbol>,
100}
101
102#[derive(Debug, Clone, Serialize, Deserialize)]
103pub enum ResolvedSymbol {
104 Local(usize),
105 External {
106 file_path: String,
107 symbol_name: String,
108 },
109}
110
111#[derive(Debug, Clone, Serialize, Deserialize)]
112pub struct LocalFileSymbols {
113 pub file_path: String,
114 pub definitions: Vec<SymbolDefinition>,
115 pub imports: Vec<ImportRecord>,
116 pub exports: Vec<ExportRecord>,
117 pub references: Vec<SymbolReference>,
118}