Skip to content

Fix pre-existing clippy errors so cargo clippy --all-targets passes (#21)#25

Open
kriszyp wants to merge 2 commits into
mainfrom
kris/clippy-cleanup-21
Open

Fix pre-existing clippy errors so cargo clippy --all-targets passes (#21)#25
kriszyp wants to merge 2 commits into
mainfrom
kris/clippy-cleanup-21

Conversation

@kriszyp

@kriszyp kriszyp commented Jul 8, 2026

Copy link
Copy Markdown
Member

Closes #21.

cargo clippy --all-targets failed on main with 12 errors under #![deny(clippy::all)] (clippy 1.94) — the lint documented in CLAUDE.md starts red for any contributor running it locally, and a future CI toolchain bump would break the build. All are in files untouched by the current feature branches.

Fixes (mechanical, no behavior change)

File Lint Fix
sni.rs needless_borrow ×3 extract_sni/compute_ja3 take slices — dropped the &
proxy_conn.rs ×2, http_listener.rs ×1 io_other_error std::io::Error::new(ErrorKind::Other, e)std::io::Error::other(e)
http_listener.rs, listener.rs useless_conversion TcpListener::from_std(socket.into())(socket)
http_listener.rs, http_proxy.rs empty_line_after_doc_comment these were module-level docs mis-written as ///; converted to //! (correct fix, not just deleting the blank line)
proxy.rs type_complexity extracted a ParsedProtectionConfig type alias
proxy.rs iter().cloned().collect() to_vec()
http_listener.rs (unused var warning) excess_excess

Result: cargo clippy --all-targets is clean. The remaining 17 warnings are all pre-existing dead_code-style ones on test/unused helpers — those don't gate under clippy::all and are left for a separate cleanup.

Notes

  • No cargo fmt. The repo has no rustfmt.toml and uses tabs; rustfmt's default is spaces, so a blanket format churns all ~16 files. Edits are kept tab-clean. Suggested follow-up: add a rustfmt.toml (hard_tabs = true) so local cargo fmt agrees with the tree, and pin/document the clippy version CI uses.
  • Unrelated pre-existing failure: server.spec.ts:142 asserts status.version === '0.4.0' but the HEAD commit "Sync platform package versions to 0.5.0" bumped package.json to 0.5.0, so npm test is red on main independent of this PR (this PR touches no TS/version files). Filing/fixing separately.

🤖 Generated with Claude Code

…#21)

12 clippy errors under `#![deny(clippy::all)]` (clippy 1.94) failed the
documented local lint on files untouched by feature branches:

- sni.rs: 3× needless_borrow (extract_sni/compute_ja3 take slices)
- proxy_conn.rs, http_listener.rs: 3× io_other_error → std::io::Error::other
- http_listener.rs, listener.rs: 2× useless_conversion (TcpListener→TcpListener)
- http_listener.rs, http_proxy.rs: 2× empty_line_after_doc_comment — these
  were module-level docs mis-written as `///`; converted to `//!`
- proxy.rs: type_complexity → ParsedProtectionConfig type alias
- proxy.rs: iter().cloned().collect() → to_vec()

Also silences one unused-variable warning (excess → _excess). Mechanical;
no behavior change. Formatting left as-is (repo has no rustfmt.toml and uses
tabs; a blanket `cargo fmt` would churn the whole tree).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kriszyp kriszyp requested review from DavidCockerill and heskew July 8, 2026 21:00

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request performs several code cleanups and refactorings across multiple Rust files. Key changes include converting module-level doc comments to inner doc comments, simplifying TcpListener::from_std calls by removing redundant .into() conversions, utilizing the cleaner std::io::Error::other constructor, introducing a type alias ParsedProtectionConfig for improved readability, simplifying a vector cloning operation, and removing unnecessary references when passing struct fields. There are no review comments, and I have no additional feedback to provide.

Follow-ups from #21 review:

- rustfmt.toml (hard_tabs = true): prevents cargo fmt from reformatting
  the tab-indented tree to spaces. Doesn't make `cargo fmt --check` pass
  clean — the codebase also hand-compacts some expressions (single-line
  if/else, condensed let-else) that rustfmt would still rewrite — so no
  fmt gate is added here; a full reformat is a separate decision.
- rust-toolchain.toml pinning 1.94.1 + clippy/rustfmt components, so
  local and CI use the same toolchain.
- New `lint` CI job running `cargo clippy --all-targets`. CI previously
  ran no clippy step at all (npm run build never invokes it), which is
  how #21's regressions went unnoticed; this makes clippy::all a
  required check going forward.
- server.spec.ts: the status.json version assertion hardcoded '0.4.0'
  and went stale the moment package.json was bumped to 0.5.0. Now reads
  the version from package.json instead of a literal, so it can't drift
  again on the next bump.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cargo clippy --all-targets fails on main (10 pre-existing errors under deny(clippy::all), clippy 1.94)

1 participant