Skip to content

chore(rust-plugins): add a local quality gate script, pin the toolchain, dedupe the generated parser - #6417

Open
julienmathis wants to merge 1 commit into
developfrom
chore/rust-quality-gate
Open

julienmathis wants to merge 1 commit into
developfrom
chore/rust-quality-gate

Conversation

@julienmathis

Copy link
Copy Markdown
Contributor

Summary

Adds rust-plugins/scripts/check.sh: a single local command (fmt check, clippy --all-targets -D warnings, test, and a reachable-panic scan) matching what the lint/build CI jobs enforce, plus a stricter local-only check not in CI: no panic!()/.unwrap() may be reachable from production code (outside #[cfg(test)]) — a panic reachable from untrusted input (a malformed JSON definition, a malicious SNMP response) turns a reportable UNKNOWN into a crash. Wired into .githooks/pre-commit.d/ so it runs automatically for contributors using the repository's git hooks (git config core.hooksPath .githooks).

Pins the toolchain via rust-toolchain.toml (1.97.1 + rustfmt/clippy): zero-warning is only meaningful with a fixed lint set.

Removes a duplicate lalrpop_mod!(grammar) in main.rs — the ~4500-line generated parser was being compiled twice (once per declaration site); main.rs never referenced the grammar module directly, only compute::mod.rs does. Also drops the needless returns clippy flags in grammar.lalrpop's own action code.

Test plan

…in, dedupe the generated parser

Adds rust-plugins/scripts/check.sh: a single local command (fmt check,
clippy --all-targets -D warnings, test, and a reachable-panic scan)
matching what the "lint"/"build" CI jobs enforce, plus a stricter
local-only check the panic scan isn't in CI: no panic!()/.unwrap() may
be reachable from production code (outside #[cfg(test)]), since a panic
reachable from untrusted input (a malformed JSON definition, a
malicious SNMP response) turns a reportable UNKNOWN into a crash.
Wired into .githooks/pre-commit.d/ so it runs automatically for
contributors using the repository's git hooks.

Pins the toolchain via rust-toolchain.toml (1.97.1 + rustfmt/clippy):
zero-warning is only meaningful with a fixed lint set.

Removes a duplicate lalrpop_mod!(grammar) in main.rs — the ~4500-line
generated parser was being compiled twice (once per declaration site);
main.rs never referenced the grammar module directly, only
compute::mod.rs does. Also drops the needless `return`s clippy flags
in grammar.lalrpop's own action code.

Test plan:
- cargo build --release / cargo test: 67 passed, 0 failed
- confirmed only one `lalrpop_mod!(grammar)` remains in the crate
- ./scripts/check.sh's fmt/clippy steps currently flag the pre-existing
  findings #6415 fixes, and its panic scan currently reports the 103
  pre-existing hits #6410 (70+15, false positives from two ungated test
  modules) and #6411 (12+5+1, genuinely reachable panics) fix — verified
  by hand that the counts match exactly. Once those merge, this script
  reads ALL CHECKS PASSED.
@julienmathis
julienmathis requested review from a team as code owners September 4, 2026 12:34
@julienmathis
julienmathis requested review from Evan-Adam, emgcentreon, kabreu and paloth and removed request for a team September 4, 2026 12:34

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.

1 participant