fix(rust): resolve cargo clippy warnings and gate clippy in CI (#2096 follow-up) - #2484
Merged
Merged
Conversation
…low-up) Clears all 102 cargo clippy warnings (21 lint categories) reported against crates/codegraph-core, per issue #2326. Mechanical, behavior-preserving simplifications (17 categories, ~84 sites): unnecessary_map_or, double_ended_iterator_last, manual_contains, collapsible_match, collapsible_if, doc_lazy_continuation, manual_pattern_char_comparison, explicit_counter_loop, needless_lifetimes, needless_borrow, redundant_closure, redundant_pattern_matching, manual_flatten, needless_range_loop, nonminimal_bool, unnecessary_unwrap, manual_is_multiple_of. Each `.split(...).last()` -> `.next_back()` site was individually checked to confirm no other `.last()` (e.g. slice `.last()`) call was accidentally swept up by the same substitution. Judgment-required categories (4 categories, 18 sites), evaluated individually: - ptr_arg (2): narrowed `&mut Vec<ScopeFrame>` to `&mut [ScopeFrame]` in ast_analysis/dataflow.rs, matching the existing slice convention already used by sibling functions (e.g. find_binding, handle_return_stmt) in the same file. - new_without_default (1): added `impl Default for ParseTreeCache` that delegates to the existing `#[napi(constructor)] fn new()`, without touching the constructor itself. - type_complexity (4): introduced named type aliases (LeafRow/CallableRow, ReturnTypeIndex/GlobalReturnTypes, NodeEdge, a test-only TestReexportEntry) for the flagged signatures, applied consistently to sibling functions with the same shape where present. - too_many_arguments (11): all 11 sites are internal (non-pub) hot-path functions in the call/edge-resolution and dataflow subsystems, which must stay behaviorally identical to the TS/WASM engine per CLAUDE.md's dual-engine mandate. A params-struct refactor there is exactly the kind of hasty structural change issue #2326 itself warns against, so each site got a targeted `#[allow(clippy::too_many_arguments)]` with a one-line justification instead. Deferred refactor tracked in #2481. Verified: cargo test --workspace (1011 passed), cargo fmt --check, npm test (5231 passed), npm run lint, and the dual-engine parity suite (tests/engines/ + tests/integration/build-parity.test.ts, 122 passed) all clean. `node scripts/parity-compare.mjs --hybrid` and `--dataflow` surfaced two divergences (jelly-micro bind.js/fun.js self-referential dyn=1 edges; native producing far fewer dataflow vertices than WASM for several JS/TS/ pts-javascript fixtures) — both reproduce identically on an unmodified origin/main checkout, confirmed via an isolated worktree, so they predate this change and are filed separately as #2482 and #2483. docs check acknowledged: internal code-quality cleanup + lint-category triage with no user-facing behavior change or new documented feature: no README/CLAUDE.md/ROADMAP.md update applies.
Adds clippy to the Setup Rust step's components list and a new "Check clippy" step running `cargo clippy --workspace --all-targets -- -D warnings` right after the existing `cargo fmt --check` step, now that the crate is clippy-clean (previous commit). Mirrors how #2096 added the fmt gate to this same job. Removes the now-stale comment saying clippy was deliberately not gated yet. docs check acknowledged: CI workflow change only, no user-facing behavior or documented feature change.
Contributor
Greptile SummaryThe PR clears existing Rust clippy warnings and makes clippy a required CI check.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Reviews (2): Last reviewed commit: "fix(rust): remove redundant borrow flagg..." | Re-trigger Greptile |
…hain CI's rust-toolchain floats to latest stable (1.97.0), one minor version ahead of what was tested locally (1.95.0) when this PR's clippy pass landed. That gap introduced exactly one new warning at a site this PR never touched: a redundant `&` in a format! argument in insert_symbol_nodes. Updated the local toolchain to 1.97.1 and re-ran `cargo clippy --workspace --all-targets -- -D warnings` to confirm this was the only drift-induced gap, not a first instance of a recurring one. docs check acknowledged: same internal code-quality fix as the parent commits, no README/CLAUDE.md/ROADMAP.md update applies.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Problem
Follow-up to #2096: that issue's
cargo fmthalf landed (repo-wide reformat +cargo fmt --checkCI gate). This PR does thecargo clippyhalf — as of #2096's investigation,cargo clippyreported ~98 warnings againstcrates/codegraph-core, and nothing in CI ran clippy.What changed
Triaged 102 unique warning sites (as of this PR) across 21 lint categories:
unnecessary_map_or,double_ended_iterator_last,manual_contains,collapsible_match,doc_lazy_continuation,manual_pattern_char_comparison,collapsible_if,explicit_counter_loop,needless_lifetimes,needless_borrow,redundant_closure,redundant_pattern_matching,manual_flatten,needless_range_loop,nonminimal_bool,unnecessary_unwrap,manual_is_multiple_of.ptr_arg(narrowed&mut Vec<T>params to&mut [T]where the function never grows/shrinks the collection),new_without_default(added aDefaultimpl delegating to the existing constructor),type_complexity(named type aliases for two-tuple-of-maps return types).#[allow]+ deferred:too_many_arguments, all in the parity-critical call/edge-resolution hot path (dataflow.rs,pipeline.rs,build_edges.rs,import_edges.rs). A params-struct refactor here is exactly the kind of hasty structural change this issue's own body warns against; each site got a targeted (not blanket)#[allow(clippy::too_many_arguments)]with a justification comment. Refactor tracked in a follow-up: Closes... see below.Added the CI gate:
cargo clippy --workspace --all-targets -- -D warningsin therust-checkjob, right after the existingcargo fmt -- --checkstep, mirroring how #2096 added that gate. Addedclippyto the job'srust-toolchaincomponents.Follow-ups filed (out of scope for this PR)
too_many_argumentssites.origin/main, unrelated to this change) dual-engine parity divergence:jelly-microself-referential dynamic call edges.origin/main, unrelated to this change) dual-engine parity divergence: native engine emits far fewer dataflow vertices than WASM for several JS/TS/pts-javascript fixtures.Test plan
cargo clippy --workspace --all-targets -- -D warnings→ 0 warningscargo test --workspace→ 1011 passedcargo fmt -- --check→ cleannpm test, native addon rebuilt fresh) → 5231 passed, 30 skipped, 2 todo, 0 failednpm run lint→ cleannode dist/cli.js diff-impact <merge-base>→ no function-level impact (all touched files are undercrates/**, outside codegraph's own JS/TS analysis scope, or the CI workflow file)Closes #2326