refactor: drop stale and redundant dependencies#199
Merged
Conversation
Audit the full direct dependency set in `Cargo.toml`, then remove or replace crates that were dead, redundant with the standard library, or duplicated with an existing dependency. Five crates (`arrayvec`, `ctrlc`, `directories`, `signal-hook 0.4.4`, plus the macOS `objc2`/`block2`/`dispatch2` chain pulled in by `ctrlc`) are now completely gone from the build graph; three more (`lazy_static`, `once_cell`, `fastrand`) remain transitively but are no longer directly referenced by our code. Replacements: - `lazy_static!` → `std::sync::LazyLock` in `src/ui/tui/progress.rs` (edition 2024 already mandates Rust 1.85+). - `once_cell::sync::Lazy` / `OnceCell` → `std::sync::LazyLock` / `OnceLock` across `executor/output_sync.rs`, `pty/terminal.rs`, `utils/logging.rs`, `ssh/ssh_config/env_cache/global.rs`, `ssh/config_cache/global.rs`. - `fastrand::u64(range)` → `rand::random_range(range)` in the three forwarding reconnect-jitter sites; `rand` 0.10 was already a direct dependency. - `directories::ProjectDirs` / `BaseDirs` → `dirs::config_dir` / `dirs::home_dir`, unifying on `dirs` which was already used in 16 other sites and produces equivalent platform paths. - `ctrlc::set_handler` → `tokio::signal::ctrl_c` inside a `tokio::spawn`, guarded by `Handle::try_current` to preserve the previous best-effort semantics in non-runtime contexts. The only caller (`execute_traditional`) is already async, and the matching test runs under `#[tokio::test]`. - `signal-hook = "0.4.4"` → `"0.3"` so we share the same instance `crossterm` already pulls in via `signal-hook-mio`. Our usage (`Signals::new`, `Signals::forever`, `consts::SIGWINCH`) has identical signatures across both major lines, so no source change was needed — only the `Cargo.toml` pin. The `arrayvec` crate was declared but unused anywhere in the source tree, so it is simply dropped. Build, full `cargo test -p bssh` (1303 tests), `cargo clippy --all-targets`, and `cargo fmt --check` all pass. `Cargo.lock` loses 76 lines including the entire `signal-hook 0.4.4` subtree.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Audit the full direct dependency set in
Cargo.toml, then remove or replace crates that were dead, redundant with the standard library, or duplicated with an existing dependency.Build graph wins
arrayvec,ctrlc(+ macOSobjc2/block2/dispatch2chain it pulled in),directories,signal-hook 0.4.4.lazy_static,once_cell,fastrand.Cargo.lockshrinks by 76 lines.Replacements
lazy_static!std::sync::LazyLock(edition 2024 → Rust 1.85+)src/ui/tui/progress.rs(3 regex)once_cell::sync::Lazy/OnceCellstd::sync::LazyLock/OnceLockexecutor/output_sync.rs,pty/terminal.rs,utils/logging.rs,ssh/ssh_config/env_cache/global.rs,ssh/config_cache/global.rsfastrand::u64(range)rand::random_range(range)(rand0.10 already direct dep)directories::ProjectDirs/BaseDirsdirs::config_dir/dirs::home_dir(unify ondirs, already used in 16 sites)config/loader.rs,ssh/known_hosts.rsctrlc::set_handlertokio::signal::ctrl_cintokio::spawn, guarded byHandle::try_currentcommands/interactive_signal.rssignal-hook = "0.4.4"signal-hook = "0.3"(shares the instance crossterm already pulls in viasignal-hook-mio); identical signatures forSignals::new,forever,consts::SIGWINCH— no source changeCargo.tomlonlyarrayvecwas declared but unused anywhere in the source tree, so it is simply dropped.Test plan
cargo build --workspacecargo test -p bssh— 1303 tests passing, 0 failurescargo clippy -p bssh --all-targets --no-deps— no warningscargo fmt -p bssh --check— cleansignal-hookdedupes to a single 0.3.18 instance shared with crossterm