Skip to content

Commit ac59396

Browse files
goxberryclaude
andcommitted
refactor(lading): drop expect_used quarantines and annotate bins
Annotate the lading bin entry points (lading, captool, payloadtool), drop the `#![allow(clippy::expect_used)]` quarantine from lib.rs and the three bin entrypoints, and annotate previously-masked production sites in process_tree, tcp_rr, and udp generators that the quarantine drop surfaces. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 622f36e commit ac59396

7 files changed

Lines changed: 55 additions & 16 deletions

File tree

lading/src/bin/captool/main.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
//! Capture analysis tool for lading capture files.
22
33
#![expect(clippy::print_stdout)]
4-
// Quarantine: workspace denies `clippy::expect_used`, but this binary still has
5-
// production `.expect()` sites awaiting cleanup. Remove once cleaned up.
6-
#![allow(clippy::expect_used)]
74

85
mod analyze;
96

@@ -75,6 +72,10 @@ pub enum Error {
7572

7673
#[tokio::main(flavor = "current_thread")]
7774
#[expect(clippy::too_many_lines)]
75+
#[expect(
76+
clippy::expect_used,
77+
reason = "FIXME: line read and JSON deserialization should surface as Error variants rather than panicking; tracked for follow-up. Task join panics are intentional propagation of inner panics."
78+
)]
7879
async fn main() -> Result<(), Error> {
7980
tracing_subscriber::fmt()
8081
.with_span_events(FmtSpan::FULL)
@@ -230,6 +231,10 @@ async fn main() -> Result<(), Error> {
230231
Ok(())
231232
}
232233

234+
#[expect(
235+
clippy::expect_used,
236+
reason = "FIXME: line read and JSON deserialization should surface as Error variants rather than panicking; tracked for follow-up. Task join panics are intentional propagation of inner panics."
237+
)]
233238
async fn validate_capture(capture_path_str: &str, min_seconds: Option<u64>) -> Result<(), Error> {
234239
let capture_path = path::Path::new(capture_path_str);
235240
if !capture_path.exists() {
@@ -286,6 +291,10 @@ async fn validate_capture(capture_path_str: &str, min_seconds: Option<u64>) -> R
286291
report_validation_result(&result, min_seconds)
287292
}
288293

294+
#[expect(
295+
clippy::expect_used,
296+
reason = "ValidationResult::first_error is Some whenever is_valid() returns false; the unreachable None branch indicates a programming error in the validator"
297+
)]
289298
fn report_validation_result(
290299
result: &lading_capture::validate::ValidationResult,
291300
min_seconds: Option<u64>,

lading/src/bin/lading.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
//! Main lading binary for load testing.
22
3-
// Quarantine: workspace denies `clippy::expect_used`, but this binary still has
4-
// production `.expect()` sites awaiting cleanup. Remove once cleaned up.
5-
#![allow(clippy::expect_used)]
6-
73
use std::{
84
env,
95
fmt::{self, Display},
@@ -105,6 +101,10 @@ impl Display for CliKeyValues {
105101
impl FromStr for CliKeyValues {
106102
type Err = String;
107103

104+
#[expect(
105+
clippy::expect_used,
106+
reason = "compile-time-constant regex literal; capture group 0 always exists on a successful match"
107+
)]
108108
fn from_str(input: &str) -> Result<Self, Self::Err> {
109109
// A key matches `[[:alnum:]_-]+` (letters, digits, underscores,
110110
// hyphens) and a value conforms to `[[:alpha:]_:,`. A key is always
@@ -307,6 +307,10 @@ fn validate_config(config_path: &str) -> Result<Config, Error> {
307307
}
308308
}
309309

310+
#[expect(
311+
clippy::expect_used,
312+
reason = "PIDs from --target-pid CLI argument fit in i32 on supported platforms; a failure indicates a platform invariant violation"
313+
)]
310314
fn get_config(args: &LadingArgs, config: Option<String>) -> Result<Config, Error> {
311315
let mut config = if let Some(contents) = config {
312316
// Config provided via environment variable - parse as single file
@@ -401,6 +405,10 @@ fn get_config(args: &LadingArgs, config: Option<String>) -> Result<Config, Error
401405
}
402406

403407
#[expect(clippy::too_many_lines)]
408+
#[expect(
409+
clippy::expect_used,
410+
reason = "telemetry is validated in get_config before reaching inner_main; the metrics recorder and capture manager are global singletons whose set-once installation is part of the documented startup contract"
411+
)]
404412
async fn inner_main(
405413
experiment_duration: Duration,
406414
warmup_duration: Duration,

lading/src/bin/payloadtool.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
33
#![expect(clippy::print_stdout)]
44
#![expect(clippy::print_stderr)]
5-
// Quarantine: workspace denies `clippy::expect_used`, but this binary still has
6-
// production `.expect()` sites awaiting cleanup. Remove once cleaned up.
7-
#![allow(clippy::expect_used)]
85

96
/// Memory allocation tracking for payloadtool statistics.
107
///
@@ -284,6 +281,10 @@ struct Args {
284281
dump: Option<PathBuf>,
285282
}
286283

284+
#[expect(
285+
clippy::expect_used,
286+
reason = "Byte::from_u128 only fails on 0; total_bytes is NonZeroU32, and the diagnostic-path total_generated_bytes path inherits the same invariant from the caller"
287+
)]
287288
fn generate_and_check(
288289
config: &lading_payload::Config,
289290
seed: [u8; 32],
@@ -367,6 +368,10 @@ fn generate_and_check(
367368
}
368369

369370
#[expect(clippy::too_many_lines)]
371+
#[expect(
372+
clippy::expect_used,
373+
reason = "FIXME: maximum_prebuild_cache_size_bytes is user-supplied config; a zero value should surface as a recoverable error rather than panicking. Tracked for follow-up."
374+
)]
370375
fn check_generator(config: &generator::Config, args: &Args) -> Result<Option<Fingerprint>> {
371376
match &config.inner {
372377
generator::Inner::FileGen(g) => {

lading/src/generator/process_tree.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,10 @@ impl Process {
441441
///
442442
/// Function will panic if the process execution fails.
443443
///
444+
#[expect(
445+
clippy::expect_used,
446+
reason = "the iterator is populated from the caller's pre-validated process tree; missing nodes or missing exit codes indicate a programming error in the tree construction"
447+
)]
444448
pub fn spawn_tree(nodes: &VecDeque<Process>, sleep_ns: u32) -> Result<(), Error> {
445449
let mut iter = nodes.iter().peekable();
446450
let mut pids_to_wait: FxHashSet<Pid> = FxHashSet::default();

lading/src/generator/tcp_rr.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ impl TcpRr {
128128
/// # Panics
129129
///
130130
/// Panics if `addr` cannot be resolved to a socket address.
131+
#[expect(
132+
clippy::expect_used,
133+
reason = "FIXME: config.addr is user-supplied; parse failure should surface as an Error variant instead of panicking. Tracked for follow-up."
134+
)]
131135
pub async fn spin(self) -> Result<(), Error> {
132136
if self.config.threads > self.config.flows {
133137
return Err(Error::Config(format!(
@@ -233,6 +237,10 @@ impl TcpRr {
233237
}
234238
}
235239

240+
#[expect(
241+
clippy::expect_used,
242+
reason = "mio Poll creation, nonblocking setup, and registry registration fail only on system resource exhaustion; documented contract for the per-thread client startup"
243+
)]
236244
fn client_thread_main(
237245
addr: SocketAddr,
238246
num_flows: u16,

lading/src/generator/udp.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ impl Udp {
142142
/// Function will panic if user has passed zero values for any byte
143143
/// values. Sharp corners.
144144
#[expect(clippy::cast_possible_truncation)]
145+
#[expect(
146+
clippy::expect_used,
147+
reason = "FIXME: config.addr is user-supplied; socket address parsing failures should surface as Error variants instead of panicking. Tracked for follow-up."
148+
)]
145149
pub fn new(
146150
general: General,
147151
config: &Config,
@@ -179,9 +183,9 @@ impl Udp {
179183
for i in 0..worker_count {
180184
let throttle =
181185
create_throttle(config.throttle.as_ref(), config.bytes_per_second.as_ref())?
182-
.divide(
183-
NonZeroU32::new(worker_count.into()).expect("worker_count is always >= 1"),
184-
)?;
186+
.divide(NonZeroU32::new(worker_count.into()).unwrap_or_else(|| {
187+
unreachable!("worker_count is NonZeroU16, always >= 1")
188+
}))?;
185189

186190
let mut worker_labels = labels.clone();
187191
if worker_count > 1 {
@@ -236,6 +240,10 @@ struct UdpWorker {
236240
}
237241

238242
impl UdpWorker {
243+
#[expect(
244+
clippy::expect_used,
245+
reason = "the wait_for_block branch is gated on `connection.is_some()` in the tokio::select! arm; the Option is guaranteed Some when this branch fires"
246+
)]
239247
async fn spin(mut self) -> Result<(), Error> {
240248
debug!("UDP generator worker running");
241249
let mut connection = Option::<UdpSocket>::None;

lading/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
#![deny(clippy::cargo)]
99
#![expect(clippy::cast_precision_loss)]
1010
#![expect(clippy::multiple_crate_versions)]
11-
// Quarantine: workspace denies `clippy::expect_used`, but this crate still has
12-
// production `.expect()` sites awaiting cleanup. Remove once cleaned up.
13-
#![allow(clippy::expect_used)]
1411

1512
use http_body_util::BodyExt;
1613

0 commit comments

Comments
 (0)