Fix all clippy lints and pass CI checks
- Box large enum variants in EventData to reduce memory footprint - Add Default trait implementations for types with new() methods - Replace or_insert_with(Vec::new) with or_default() - Convert vec init+push patterns to vec! macro - Fix field reassignment with default initialization - Convert match to if for simple equality checks - Remove unused Backend type parameters from TUI draw functions - Apply rustfmt formatting All tests passing (24 total). Zero clippy warnings. Ready for CI/CD.
This commit is contained in:
@@ -379,19 +379,16 @@ impl App {
|
||||
}
|
||||
|
||||
pub fn select_item(&mut self) {
|
||||
match self.current_tab {
|
||||
TabIndex::Processes => {
|
||||
if let Some(i) = self.processes_state.selected() {
|
||||
if let Some(process) = self.processes.get(i) {
|
||||
self.selected_process = Some(process.clone());
|
||||
self.add_log_message(format!(
|
||||
"Selected process: {} (PID: {})",
|
||||
process.name, process.pid
|
||||
));
|
||||
}
|
||||
if self.current_tab == TabIndex::Processes {
|
||||
if let Some(i) = self.processes_state.selected() {
|
||||
if let Some(process) = self.processes.get(i) {
|
||||
self.selected_process = Some(process.clone());
|
||||
self.add_log_message(format!(
|
||||
"Selected process: {} (PID: {})",
|
||||
process.name, process.pid
|
||||
));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ async fn run_app<B: Backend>(terminal: &mut Terminal<B>, app: Arc<Mutex<App>>) -
|
||||
// Draw the UI
|
||||
terminal.draw(|f| {
|
||||
if let Ok(app) = app.try_lock() {
|
||||
ui::draw::<CrosstermBackend<std::io::Stdout>>(f, &app);
|
||||
ui::draw(f, &app);
|
||||
}
|
||||
})?;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ mod colors {
|
||||
|
||||
use colors::*;
|
||||
|
||||
pub fn draw<B: Backend>(f: &mut Frame, app: &App) {
|
||||
pub fn draw(f: &mut Frame, app: &App) {
|
||||
let size = f.size();
|
||||
|
||||
// Create main layout
|
||||
@@ -46,23 +46,23 @@ pub fn draw<B: Backend>(f: &mut Frame, app: &App) {
|
||||
.split(size);
|
||||
|
||||
// Draw header
|
||||
draw_header::<B>(f, chunks[0], app);
|
||||
draw_header(f, chunks[0], app);
|
||||
|
||||
// Draw main content based on selected tab
|
||||
match app.current_tab {
|
||||
TabIndex::Overview => draw_overview::<B>(f, chunks[1], app),
|
||||
TabIndex::Processes => draw_processes::<B>(f, chunks[1], app),
|
||||
TabIndex::Detections => draw_detections::<B>(f, chunks[1], app),
|
||||
TabIndex::Memory => draw_memory::<B>(f, chunks[1], app),
|
||||
TabIndex::Logs => draw_logs::<B>(f, chunks[1], app),
|
||||
TabIndex::Overview => draw_overview(f, chunks[1], app),
|
||||
TabIndex::Processes => draw_processes(f, chunks[1], app),
|
||||
TabIndex::Detections => draw_detections(f, chunks[1], app),
|
||||
TabIndex::Memory => draw_memory(f, chunks[1], app),
|
||||
TabIndex::Logs => draw_logs(f, chunks[1], app),
|
||||
TabIndex::ThreatIntel => {} // TODO: Implement threat intel view
|
||||
}
|
||||
|
||||
// Draw footer
|
||||
draw_footer::<B>(f, chunks[2], app);
|
||||
draw_footer(f, chunks[2], app);
|
||||
}
|
||||
|
||||
fn draw_header<B: Backend>(f: &mut Frame, area: Rect, app: &App) {
|
||||
fn draw_header(f: &mut Frame, area: Rect, app: &App) {
|
||||
let titles = app.get_tab_titles();
|
||||
let tabs = Tabs::new(titles)
|
||||
.block(
|
||||
@@ -84,7 +84,7 @@ fn draw_header<B: Backend>(f: &mut Frame, area: Rect, app: &App) {
|
||||
f.render_widget(tabs, area);
|
||||
}
|
||||
|
||||
fn draw_footer<B: Backend>(f: &mut Frame, area: Rect, app: &App) {
|
||||
fn draw_footer(f: &mut Frame, area: Rect, app: &App) {
|
||||
let help_text = match app.current_tab {
|
||||
TabIndex::Overview => {
|
||||
"Up/Down: Navigate | Tab: Switch tabs | R: Refresh | C: Clear | Q: Quit"
|
||||
@@ -112,7 +112,7 @@ fn draw_footer<B: Backend>(f: &mut Frame, area: Rect, app: &App) {
|
||||
f.render_widget(footer, area);
|
||||
}
|
||||
|
||||
fn draw_overview<B: Backend>(f: &mut Frame, area: Rect, app: &App) {
|
||||
fn draw_overview(f: &mut Frame, area: Rect, app: &App) {
|
||||
let chunks = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints([
|
||||
@@ -123,16 +123,16 @@ fn draw_overview<B: Backend>(f: &mut Frame, area: Rect, app: &App) {
|
||||
.split(area);
|
||||
|
||||
// Statistics panel
|
||||
draw_stats_panel::<B>(f, chunks[0], app);
|
||||
draw_stats_panel(f, chunks[0], app);
|
||||
|
||||
// Threat level gauge
|
||||
draw_threat_gauge::<B>(f, chunks[1], app);
|
||||
draw_threat_gauge(f, chunks[1], app);
|
||||
|
||||
// Recent detections
|
||||
draw_recent_detections::<B>(f, chunks[2], app);
|
||||
draw_recent_detections(f, chunks[2], app);
|
||||
}
|
||||
|
||||
fn draw_stats_panel<B: Backend>(f: &mut Frame, area: Rect, app: &App) {
|
||||
fn draw_stats_panel(f: &mut Frame, area: Rect, app: &App) {
|
||||
let stats_chunks = Layout::default()
|
||||
.direction(Direction::Horizontal)
|
||||
.constraints([
|
||||
@@ -204,7 +204,7 @@ fn draw_stats_panel<B: Backend>(f: &mut Frame, area: Rect, app: &App) {
|
||||
f.render_widget(perf_gauge, stats_chunks[3]);
|
||||
}
|
||||
|
||||
fn draw_threat_gauge<B: Backend>(f: &mut Frame, area: Rect, app: &App) {
|
||||
fn draw_threat_gauge(f: &mut Frame, area: Rect, app: &App) {
|
||||
let threat_level = if app.stats.malicious_processes > 0 {
|
||||
100
|
||||
} else if app.stats.suspicious_processes > 0 {
|
||||
@@ -239,7 +239,7 @@ fn draw_threat_gauge<B: Backend>(f: &mut Frame, area: Rect, app: &App) {
|
||||
f.render_widget(threat_gauge, area);
|
||||
}
|
||||
|
||||
fn draw_recent_detections<B: Backend>(f: &mut Frame, area: Rect, app: &App) {
|
||||
fn draw_recent_detections(f: &mut Frame, area: Rect, app: &App) {
|
||||
let items: Vec<ListItem> = app
|
||||
.detections
|
||||
.iter()
|
||||
@@ -277,7 +277,7 @@ fn draw_recent_detections<B: Backend>(f: &mut Frame, area: Rect, app: &App) {
|
||||
f.render_widget(list, area);
|
||||
}
|
||||
|
||||
fn draw_processes<B: Backend>(f: &mut Frame, area: Rect, app: &App) {
|
||||
fn draw_processes(f: &mut Frame, area: Rect, app: &App) {
|
||||
let chunks = Layout::default()
|
||||
.direction(Direction::Horizontal)
|
||||
.constraints([Constraint::Percentage(70), Constraint::Percentage(30)])
|
||||
@@ -334,10 +334,10 @@ fn draw_processes<B: Backend>(f: &mut Frame, area: Rect, app: &App) {
|
||||
f.render_stateful_widget(table, chunks[0], &mut state);
|
||||
|
||||
// Process details panel
|
||||
draw_process_details::<B>(f, chunks[1], app);
|
||||
draw_process_details(f, chunks[1], app);
|
||||
}
|
||||
|
||||
fn draw_process_details<B: Backend>(f: &mut Frame, area: Rect, app: &App) {
|
||||
fn draw_process_details(f: &mut Frame, area: Rect, app: &App) {
|
||||
let details = if let Some(ref process) = app.selected_process {
|
||||
format!(
|
||||
"PID: {}\nPPID: {}\nName: {}\nPath: {}\nThreads: {}",
|
||||
@@ -364,7 +364,7 @@ fn draw_process_details<B: Backend>(f: &mut Frame, area: Rect, app: &App) {
|
||||
f.render_widget(paragraph, area);
|
||||
}
|
||||
|
||||
fn draw_detections<B: Backend>(f: &mut Frame, area: Rect, app: &App) {
|
||||
fn draw_detections(f: &mut Frame, area: Rect, app: &App) {
|
||||
let items: Vec<ListItem> = app
|
||||
.detections
|
||||
.iter()
|
||||
@@ -420,7 +420,7 @@ fn draw_detections<B: Backend>(f: &mut Frame, area: Rect, app: &App) {
|
||||
f.render_stateful_widget(list, area, &mut state);
|
||||
}
|
||||
|
||||
fn draw_memory<B: Backend>(f: &mut Frame, area: Rect, app: &App) {
|
||||
fn draw_memory(f: &mut Frame, area: Rect, app: &App) {
|
||||
let chunks = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints([Constraint::Length(8), Constraint::Min(0)])
|
||||
@@ -459,7 +459,7 @@ fn draw_memory<B: Backend>(f: &mut Frame, area: Rect, app: &App) {
|
||||
f.render_widget(memory_info, chunks[1]);
|
||||
}
|
||||
|
||||
fn draw_logs<B: Backend>(f: &mut Frame, area: Rect, app: &App) {
|
||||
fn draw_logs(f: &mut Frame, area: Rect, app: &App) {
|
||||
let items: Vec<ListItem> = app
|
||||
.logs
|
||||
.iter()
|
||||
|
||||
Reference in New Issue
Block a user