Task #9518
Updated by Suri Bot 2 days ago
Requested by: @catenacyber Proposal: enable the clippy lint @unnecessary_wraps@ (pedantic, so off by default) in the Rust code, e.g. @#![deny(clippy::unnecessary_wraps)]@ in @rust/src/lib.rs@. The lint flags private functions that always return @Some(..)@ / @Ok(..)@, so the @Option@/@Result@ wrapper is useless and callers carry dead @None@/@Err@ branches. Example: https://github.com/OISF/suricata/pull/16836/changes/dbff0992492f28a265f27d756525ae8f93014716 — @http2_frame_header_static()@ always returned @Some@, and its callers had unreachable @None@ handling. h2. Current state @cargo clippy --workspace --all-features --all-targets -- --cap-lints warn -W clippy::unnecessary_wraps@ on main (d622b4f69, clippy 1.93.1) reports 30 sites: suricata crate (7): * @src/http2/parser.rs@: @http2_frame_header_static@ (fixed by the PR above) * @src/nfs/nfs4_records.rs@: @nfs4_req_getfh@, @nfs4_req_savefh@, @nfs4_req_putrootfh@ * @src/nfs/rpc_records.rs@: @parse_rpc_request_creds_unknown@ * @src/quic/frames.rs@: @parse_padding_frame@ * @src/telnet/telnet.rs@: @probe@ htp crate (23): * @connection_parser.rs@: @finalize@; @request.rs@: @request_receiver_set@; @response.rs@: @response_receiver_set@ * 20 test callbacks in @htp/src/test/{common,hybrid,main}.rs@ h2. Notes * The nom-style parsers (nfs, rpc, quic, telnet) keep the @IResult@ signature for consistency with their sibling parsers in the same @match@ dispatch. They can be simplified (callers use @?@) or get a local @#[allow(clippy::unnecessary_wraps)]@; to be decided case by case. * The htp test callbacks must match the callback type, so they also need an allow (or the lint only enabled for non-test code). * htp has @#![deny(warnings)]@, so enabling the lint there makes it a hard error. Requested by: @catenacyber