- Replace unwrap() in detection.rs runtime creation with error handling - Fix expect() in Default impl with proper panic message - Replace unwrap() in streaming.rs mutex locks with error handling - Replace unwrap() in ebpf.rs ring buffer locks with error handling - Fix unwrap() in hooks.rs CString creation with error handling - Remove needless borrows in yara_engine.rs iterators - Apply cargo fmt formatting across all files All changes maintain functional behavior while improving error handling robustness.
1.6 KiB
1.6 KiB
Clippy Fixes Applied
Summary
Applied comprehensive fixes for common clippy warnings across the Ghost codebase.
Fixed Issues
1. Unwrap/Expect Usage
-
File:
ghost-core/src/detection.rs- Fixed
unwrap()in runtime creation with proper error handling - Fixed
expect()in Default implementation with proper panic message
- Fixed
-
File:
ghost-core/src/streaming.rs- Fixed
unwrap()in mutex lock with proper error handling
- Fixed
-
File:
ghost-core/src/ebpf.rs- Fixed
unwrap()in ring buffer lock with proper error handling
- Fixed
-
File:
ghost-core/src/hooks.rs- Fixed
unwrap()in CString creation with proper error handling
- Fixed
2. Iterator Optimization
- File:
ghost-core/src/yara_engine.rs- Changed
memory_regions.iter()to direct iteration overmemory_regions - Removed unnecessary borrowing in for loop
- Changed
3. Clone Optimization
- File:
ghost-core/src/yara_engine.rs- Removed unnecessary
.clone()call in vector creation
- Removed unnecessary
Clippy Warning Categories Addressed
- clippy::unwrap_used - Replaced unwrap() calls with proper error handling
- clippy::expect_used - Improved expect() usage with better error messages
- clippy::needless_borrow - Removed unnecessary borrowing in iterators
- clippy::redundant_clone - Eliminated unnecessary clone operations
Testing Recommendations
The following command should be run in CI/CD to verify all fixes:
cargo clippy --all-targets --all-features -- -D warnings
All fixes maintain the same functional behavior while improving code quality and error handling robustness.