Skip to content

fix(backend): resolve clippy lints#107

Closed
kyscott18 wants to merge 3 commits into
reopen/100-unified-workflowfrom
reopen/101-backend-clippy
Closed

fix(backend): resolve clippy lints#107
kyscott18 wants to merge 3 commits into
reopen/100-unified-workflowfrom
reopen/101-backend-clippy

Conversation

@kyscott18

Copy link
Copy Markdown
Contributor

Replacement for #101, which GitHub marked as merged into the #100 branch before the changes landed on main.\n\nStacked on #106 to keep this PR focused on the backend clippy fixes.

Addresses 6 of the 8 clippy findings surfaced by the new rust CI job:
- needless_return (server.rs)
- match_like_matches_macro (server.rs)
- ptr_arg: &Vec<T> -> &[T] (event_filter.rs)
- needless_borrow (event_filter.rs)
- manual_is_multiple_of (event_listener.rs)
- clone_on_copy (serializable_event.rs)

Remaining (require manual judgment, deferred): large_enum_variant
(server.rs), should_implement_trait for from_str (event_listener.rs).
- large_enum_variant: box the 640-byte Event variant of EventDataOrMetrics
  (Event(Box<EventData>)). Since From::from infers its parameter type from
  the argument (deref coercion does not apply), the match-site call passes
  &*event_data to select From<&EventData>; construction uses Box::new(..).
- should_implement_trait: rename inherent EventName::from_str -> from_name
  (and its single caller) so it no longer shadows std::str::FromStr::from_str.
Surfaced once the lib compiled clean: timestamp_ns is u64, so the
(u64 - u64) as u64 casts are redundant; drop the cast and parens.
@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
monode Ready Ready Preview, Comment Jun 11, 2026 3:28pm

Request Review

@greptile-apps

greptile-apps Bot commented Jun 11, 2026

Copy link
Copy Markdown

Greptile Summary

This PR resolves a set of Clippy lints across the backend Rust codebase with no functional changes — all fixes are mechanical rewrites that leave runtime behavior identical.

  • client.rs: Removes redundant as u64 casts on u64 - u64 subtractions; timestamp_ns and the stored start values are already u64, making the cast a no-op.
  • server.rs: Boxes EventData inside EventDataOrMetrics::Event to shrink the enum's stack size, removes an explicit return, and converts an if let … { true } else { false } to matches!; all match sites are updated.
  • event_listener.rs: Renames from_str to from_name to avoid shadowing the standard FromStr::from_str interface, and switches % 100 == 0 to is_multiple_of(100).
  • event_filter.rs: Accepts &[T] instead of &Vec<T> in ArrayPrefixFilter::matches, and drops a redundant double-borrow on the is_native_transfer call.
  • serializable_event.rs: Removes an unnecessary .clone() on a Copy (u64) field.

Confidence Score: 5/5

All changes are mechanical Clippy fixes with no logic changes; safe to merge.

Every change in this PR is a direct, non-functional Clippy correction: removing redundant casts and clones on Copy types, tightening a slice parameter, dropping a double-borrow, boxing a large enum variant, replacing an explicit return, and using the matches! macro. No branching logic, data transformations, or public interfaces are altered. The rename from from_str to from_name is the only potentially broad change, and the single internal call site in event_to_data is correctly updated; the Rust compiler would catch any missed callers.

No files require special attention.

Important Files Changed

Filename Overview
backend/src/bin/client.rs Removes two redundant as u64 casts on u64–u64 timestamp subtractions; semantics unchanged.
backend/src/lib/event_filter.rs Switches &Vec<T> to &[T] in ArrayPrefixFilter::matches and removes a redundant double-borrow on is_native_transfer.
backend/src/lib/event_listener.rs Renames from_strfrom_name (all call sites updated) and uses is_multiple_of(100) in the debug log gate.
backend/src/lib/serializable_event.rs Drops an unnecessary .clone() on a u64 Copy field.
backend/src/lib/server.rs Boxes EventData in EventDataOrMetrics::Event to reduce enum stack footprint; removes explicit return and converts if let boolean pattern to matches!.

Sequence Diagram

sequenceDiagram
    participant Ring as Event Ring
    participant Listener as run_event_listener
    participant Forwarder as run_event_forwarder_task
    participant Broadcast as broadcast::Sender<EventDataOrMetrics>
    participant Client as client_write_task (per WS client)

    Ring->>Listener: raw ExecEvent
    Listener->>Listener: EventName::from_name(name)?
    Listener->>Forwarder: EventData (mpsc)
    Forwarder->>Forwarder: enrich txn_hash, update TPSTracker
    Forwarder->>Broadcast: "EventDataOrMetrics::Event(Box<EventData>)"
    alt BlockEnd
        Forwarder->>Broadcast: EventDataOrMetrics::TopAccesses(...)
    end
    alt BlockStart
        Forwarder->>Broadcast: EventDataOrMetrics::TPS(...)
    end
    Broadcast->>Client: EventDataOrMetrics (cloned)
    Client->>Client: "process_event -> SerializableEventData::from(&*event_data)"
    Client->>Client: filter.matches_event(...)
    Client-->>WS: ServerMessage::Events / TopAccesses / TPS (JSON)
Loading

Reviews (1): Last reviewed commit: "fix(backend): remove redundant u64 casts..." | Re-trigger Greptile

@kyscott18

Copy link
Copy Markdown
Contributor Author

Superseded by #109. The first replacement branch included the CI commits as its base; #109 is rebuilt from main with only the clippy fixes so the stack can merge cleanly.

@kyscott18 kyscott18 closed this Jun 11, 2026
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.

1 participant