Skip to content

chore(rust-plugins): zero-warning codebase — fmt + clippy -D warnings, CI gate - #6543

Open
omercier wants to merge 1 commit into
developfrom
CTOR-2613-rust-lints
Open

omercier wants to merge 1 commit into
developfrom
CTOR-2613-rust-lints

Conversation

@omercier

Copy link
Copy Markdown
Contributor

Original PR: #6415 6415

Summary

Fixes every cargo clippy --all-targets warning in rust-plugins (unneeded returns, manual Option::map, needless borrows, &Vec/&Vec<T> instead of slices, legacy std::f64::INFINITY, collapsible ifs, unused lifetimes, useless .into() conversions, dead/unused imports, from_over_into on Status) and applies cargo fmt, without changing any runtime behavior.

Notable non-mechanical fixes:

  • output::OutputFormatter's inherent to_string() (shadowing the ToString trait) becomes a proper impl Display; call sites are unaffected since ToString is blanket-implemented for Display.
  • Three test modules (compute/mod.rs, compute/lexer.rs, compute/threshold.rs) lack #[cfg(test)] (see chore(rust-plugins): gate test modules behind #[cfg(test)] #6410): their imports/helpers are only used by #[test] fn bodies, which a plain (non-test) build strips, so clippy's default pass always flags them as unused regardless of gating elsewhere. Silenced locally with #[allow(unused_imports, dead_code)] rather than duplicating the #[cfg(test)] fix here, to avoid the two PRs conflicting on the same line — once chore(rust-plugins): gate test modules behind #[cfg(test)] #6410 merges these allows become redundant but harmless (also safe to drop them then).
  • snmp::mod.rs: a few imports (FailedToConnectToHost, InvalidSnmpPduDecode/Encode, log::info/trace, UdpSocket) are used only by the #[cfg(not(test))] variant of get_data_from_udp; moved local to that function instead of importing them crate-wide.

Adds a lint CI job (cargo fmt --check + cargo clippy --all-targets --release -- -D warnings) alongside the existing build/test job, so regressions are caught going forward.

Test plan

  • cargo fmt --check: clean
  • cargo clippy --all-targets --release -- -D warnings: clean
  • cargo build --release: succeeds
  • cargo test: 67 passed, 0 failed

…, CI gate

Fixes every cargo clippy --all-targets warning in rust-plugins (unneeded
returns, manual Option::map, needless borrows, &Vec/&Vec<T> instead of
slices, legacy std::f64::INFINITY, collapsible ifs, unused lifetimes,
useless .into() conversions, dead/unused imports, from_over_into on
Status) and applies cargo fmt, without changing any runtime behavior.

Notable non-mechanical fixes:
- output::OutputFormatter's inherent to_string() (shadowing the
  ToString trait) becomes a proper impl Display; call sites are
  unaffected since ToString is blanket-implemented for Display.
- Three test modules (compute/mod.rs, compute/lexer.rs,
  compute/threshold.rs) lack #[cfg(test)] (see the dedicated PR for
  that): their imports/helpers are only used by #[test] fn bodies,
  which a plain (non-test) build strips, so clippy's default pass always
  flags them as unused regardless of gating elsewhere. Silenced locally
  with #[allow(unused_imports, dead_code)] rather than duplicating the
  #[cfg(test)] fix here, to avoid the two PRs conflicting on the same line.
- snmp::mod.rs: a few imports (FailedToConnectToHost,
  InvalidSnmpPduDecode/Encode, log::info/trace, UdpSocket) are used only
  by the #[cfg(not(test))] variant of get_data_from_udp; moved local to
  that function instead of importing them crate-wide.

Adds a "lint" CI job (cargo fmt --check + cargo clippy --all-targets
--release -- -D warnings) alongside the existing build/test job, so
regressions are caught going forward.

Test plan:
- cargo fmt --check: clean
- cargo clippy --all-targets --release -- -D warnings: clean
- cargo build --release: succeeds
- cargo test: 67 passed, 0 failed
@omercier
omercier requested review from a team as code owners November 13, 2026 16:00
@omercier
omercier requested review from Nivoky, mushroomempires and thibaults-centreon and removed request for a team November 13, 2026 16:00

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants