Skip to content

fix(rust): resolve cargo clippy warnings and gate clippy in CI (#2096 follow-up) - #2484

Merged
carlos-alm merged 3 commits into
mainfrom
fix/issue-2326-cargo-clippy-ci-gate
Aug 13, 2026
Merged

fix(rust): resolve cargo clippy warnings and gate clippy in CI (#2096 follow-up)#2484
carlos-alm merged 3 commits into
mainfrom
fix/issue-2326-cargo-clippy-ci-gate

Conversation

@carlos-alm

Copy link
Copy Markdown
Contributor

Problem

Follow-up to #2096: that issue's cargo fmt half landed (repo-wide reformat + cargo fmt --check CI gate). This PR does the cargo clippy half — as of #2096's investigation, cargo clippy reported ~98 warnings against crates/codegraph-core, and nothing in CI ran clippy.

What changed

Triaged 102 unique warning sites (as of this PR) across 21 lint categories:

  • 17 categories, ~84 sites — mechanical, behavior-preserving fixes: 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.
  • 3 categories, 7 sites — proper refactors: ptr_arg (narrowed &mut Vec<T> params to &mut [T] where the function never grows/shrinks the collection), new_without_default (added a Default impl delegating to the existing constructor), type_complexity (named type aliases for two-tuple-of-maps return types).
  • 1 category, 11 sites — targeted #[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 warnings in the rust-check job, right after the existing cargo fmt -- --check step, mirroring how #2096 added that gate. Added clippy to the job's rust-toolchain components.

Follow-ups filed (out of scope for this PR)

Test plan

  • cargo clippy --workspace --all-targets -- -D warnings → 0 warnings
  • cargo test --workspace → 1011 passed
  • cargo fmt -- --check → clean
  • Full JS/TS suite (npm test, native addon rebuilt fresh) → 5231 passed, 30 skipped, 2 todo, 0 failed
  • npm run lint → clean
  • Dual-engine parity tests (part of the full suite above) → passed
  • node dist/cli.js diff-impact <merge-base> → no function-level impact (all touched files are under crates/**, outside codegraph's own JS/TS analysis scope, or the CI workflow file)

Closes #2326

…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.
@greptile-apps

greptile-apps Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR clears existing Rust clippy warnings and makes clippy a required CI check.

  • Adds clippy to the Rust CI toolchain and runs it across the workspace and all targets with warnings denied.
  • Applies behavior-preserving lint simplifications across native extraction, analysis, graph building, persistence, and classification code.
  • Introduces type aliases, slice-based parameters, Default support, and targeted justified lint allowances for deferred argument-structure refactors.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
.github/workflows/ci.yml Adds the clippy component and a workspace-wide all-targets clippy gate with warnings denied.
crates/codegraph-core/src/ast_analysis/dataflow.rs Replaces explicit counters with enumeration, narrows mutable vector parameters to slices, and documents a targeted lint allowance.
crates/codegraph-core/src/db/connection.rs Applies iterator and option idioms to database operations without changing reachable query-result behavior.
crates/codegraph-core/src/domain/graph/builder/pipeline.rs Introduces return-type map aliases and a documented targeted allowance while preserving pipeline behavior.
crates/codegraph-core/src/domain/graph/builder/stages/build_edges.rs Simplifies lifetimes, conditions, and option checks while retaining call-resolution and edge-emission behavior.
crates/codegraph-core/src/extractors/helpers.rs Refactors string-node traversal into a guarded match arm while preserving long- and short-string handling.
crates/codegraph-core/src/extractors/javascript.rs Applies equivalent pattern-matching, character-trimming, and condition simplifications to JavaScript extraction.
crates/codegraph-core/src/features/structure.rs Applies clippy-oriented iterator and conditional simplifications to structure analysis.

Fix All in Greploop

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.
@carlos-alm
carlos-alm merged commit 17d5f4b into main Aug 13, 2026
30 checks passed
@carlos-alm
carlos-alm deleted the fix/issue-2326-cargo-clippy-ci-gate branch August 13, 2026 13:45
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adopt cargo clippy as a CI gate (#2096 follow-up)

1 participant