-
Notifications
You must be signed in to change notification settings - Fork 0
Remove dead code and improve codebase cleanliness #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Removed unused functions and structures that were not actually used: - ngx_http_vts_log_handler(): Unused LOG_PHASE handler (actual implementation is in C wrapper) - collect_upstream_request_stats(): Unused helper function for the above handler - VtsMainConfig struct and its implementation: Unused configuration structure These functions were marked with #[allow(dead_code)] but were not actually used anywhere in the codebase. The actual LOG_PHASE handling is implemented in src/ngx_vts_wrapper.c which calls the Rust vts_track_upstream_request() function. Benefits: - Cleaner codebase with reduced maintenance overhead - Eliminates potentially confusing unused code paths - Reduces binary size slightly - All tests continue to pass (40 passed; 0 failed) - No clippy warnings introduced 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Remove unused UpstreamStatsCollector struct and implementation - Remove unused UpstreamRequestData struct and implementation - Remove global variables for upstream stats collection - Remove unused nginx integration functions - Remove corresponding test functions for dead code - Clean up unused imports (Arc, RwLock, nginx FFI types) All remaining tests (34) pass successfully with no clippy warnings. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR removes unused dead code from the Rust VTS module to improve maintainability and reduce confusion. The removed components were marked with #[allow(dead_code)] but were not actually utilized in the current architecture.
- Removes
ngx_http_vts_log_handler()andcollect_upstream_request_stats()functions that were planned for direct nginx FFI integration but are unused - Removes
UpstreamStatsCollector,UpstreamRequestData, and related infrastructure that duplicates existing functionality - Removes
VtsMainConfigstructure that was not integrated into the configuration system
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/upstream_stats.rs | Removes unused upstream statistics collection infrastructure and associated test cases |
| src/lib.rs | Removes unused LOG_PHASE handler function, helper function, and configuration structure |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| //! byte transfers, response times, and server status information. | ||
| use ngx::ffi::{ngx_http_request_t, ngx_int_t, NGX_ERROR, NGX_OK}; | ||
| use std::collections::HashMap; |
Copilot
AI
Sep 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The HashMap import is no longer used after removing the UpstreamStatsCollector and related code. This unused import should be removed to maintain code cleanliness.
| // For now, this is a placeholder | ||
|
|
||
| Ok(()) | ||
| } |
Copilot
AI
Sep 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The file appears to end abruptly after the test module. Consider adding a newline at the end of the file to follow standard formatting conventions.
Summary
This PR removes unused dead code from the codebase to improve maintainability and reduce confusion. The removed code was marked with
#[allow(dead_code)]but was not actually used anywhere in the project.Removed Dead Code
ngx_http_vts_log_handler(): Unused LOG_PHASE handler functioncollect_upstream_request_stats(): Unused helper function for upstream statistics collectionVtsMainConfig: Unused configuration structure and its implementationWhy These Were Dead Code
src/ngx_vts_wrapper.cwhich calls the Rustvts_track_upstream_request()functionBenefits
Testing
cargo clippy --all-targets --all-features -- -D warningspasses with no warningsImpact
This is a safe cleanup change with no functional impact. The removed code was never called or used, so there are no breaking changes or behavioral modifications.
🤖 Generated with Claude Code