Skip to content

Commit 1fec631

Browse files
committed
Fix all remaining clippy uninlined_format_args warnings
- Fixed all 41 clippy warnings across multiple files: - src/controller.rs: 7 format string warnings - src/graph.rs: 2 format string warnings - src/logger.rs: 1 format string warning - src/metrics.rs: 9 format string warnings - src/throttle.rs: 4 format string warnings - src/user.rs: 1 format string warning - src/util.rs: 4 format string warnings - src/lib.rs: 6 format string warnings All format strings now use inline format arguments as required by clippy. The full clippy check now passes: cargo clippy --all-targets --all-features -- -D warnings
1 parent b6c0dc7 commit 1fec631

File tree

8 files changed

+41
-71
lines changed

8 files changed

+41
-71
lines changed

src/controller.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -645,9 +645,9 @@ impl GooseAttack {
645645
} else {
646646
self.configuration.users.unwrap_or_default()
647647
};
648-
info!(
649-
"changing users from {current_users:?} to {new_users}"
650-
);
648+
info!(
649+
"changing users from {current_users:?} to {new_users}"
650+
);
651651
self.configuration.users = Some(new_users);
652652
self.reply_to_controller(
653653
message,
@@ -901,7 +901,7 @@ impl GooseAttack {
901901
}
902902
Err(e) => {
903903
// Errors can be ignored, they happen any time there are no messages.
904-
debug!("error receiving message: {}", e);
904+
debug!("error receiving message: {e}");
905905
}
906906
}
907907
};
@@ -955,12 +955,9 @@ pub(crate) async fn controller_main(
955955
};
956956

957957
// All controllers use a TcpListener port.
958-
debug!(
959-
"preparing to bind {:?} controller to: {}",
960-
protocol, address
961-
);
958+
debug!("preparing to bind {protocol:?} controller to: {address}");
962959
let listener = TcpListener::bind(&address).await?;
963-
info!("{:?} controller listening on: {}", protocol, address);
960+
info!("{protocol:?} controller listening on: {address}");
964961

965962
// Counter increments each time a controller client connects with this protocol.
966963
let mut thread_id: u32 = 0;
@@ -1277,7 +1274,7 @@ impl ControllerState {
12771274
let stream = match tokio_tungstenite::accept_async(socket).await {
12781275
Ok(s) => s,
12791276
Err(e) => {
1280-
info!("invalid WebSocket handshake: {}", e);
1277+
info!("invalid WebSocket handshake: {e}");
12811278
return;
12821279
}
12831280
};
@@ -1409,7 +1406,7 @@ impl Controller<ControllerTelnetMessage> for ControllerState {
14091406
Ok(m) => m.lines().next().unwrap_or_default(),
14101407
Err(e) => {
14111408
let error = format!("ignoring unexpected input from telnet controller: {e}");
1412-
info!("{}", error);
1409+
info!("{error}");
14131410
return Err(error);
14141411
}
14151412
};
@@ -1626,14 +1623,14 @@ impl ControllerExecuteCommand<ControllerWebSocketSender> for ControllerState {
16261623
}) {
16271624
Ok(json) => json.into(),
16281625
Err(e) => {
1629-
warn!("failed to json encode response: {}", e);
1626+
warn!("failed to json encode response: {e}");
16301627
return;
16311628
}
16321629
},
16331630
))
16341631
.await
16351632
{
1636-
info!("failed to write data to websocket: {}", e);
1633+
info!("failed to write data to websocket: {e}");
16371634
}
16381635
}
16391636
}

src/graph.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,7 @@ impl GraphData {
9696
let value = self
9797
.requests_per_second
9898
.initialize_or_increment(key, second, 1);
99-
debug!(
100-
"incremented second {} for requests per second counter: {}",
101-
second, value
102-
);
99+
debug!("incremented second {second} for requests per second counter: {value}");
103100
}
104101

105102
/// Record errors per second metric.
@@ -108,10 +105,7 @@ impl GraphData {
108105
.errors_per_second
109106
.initialize_or_increment(key, second, 1);
110107

111-
debug!(
112-
"incremented second {} for errors per second counter: {}",
113-
second, value
114-
);
108+
debug!("incremented second {second} for errors per second counter: {value}");
115109
}
116110

117111
/// Record average response time per second metric.

src/lib.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ impl GooseAttack {
666666
}
667667
}
668668
// 'u' will always be the greatest common divisor
669-
debug!("gcd: {}", u);
669+
debug!("gcd: {u}");
670670

671671
// Build a vector of vectors to be used to schedule users.
672672
let mut available_scenarios = Vec::with_capacity(self.scenarios.len());
@@ -706,7 +706,7 @@ impl GooseAttack {
706706
.take(scenarios_len)
707707
{
708708
if let Some(scenario) = scenarios.pop() {
709-
debug!("allocating 1 user from Scenario {}", scenario_index);
709+
debug!("allocating 1 user from Scenario {scenario_index}");
710710
weighted_scenarios.push(scenario);
711711
}
712712
}
@@ -783,7 +783,7 @@ impl GooseAttack {
783783
)?);
784784
user_count += 1;
785785
if user_count == total_users {
786-
debug!("created {} weighted_users", user_count);
786+
debug!("created {user_count} weighted_users");
787787
return Ok(weighted_users);
788788
}
789789
}
@@ -1415,7 +1415,7 @@ impl GooseAttack {
14151415
} else {
14161416
Duration::from_millis(goose_attack_run_state.adjust_user_in_ms as u64)
14171417
};
1418-
debug!("sleeping {:?}...", sleep_duration);
1418+
debug!("sleeping {sleep_duration:?}...");
14191419
goose_attack_run_state.drift_timer =
14201420
util::sleep_minus_drift(sleep_duration, goose_attack_run_state.drift_timer)
14211421
.await;
@@ -1488,7 +1488,7 @@ impl GooseAttack {
14881488
.unwrap()
14891489
.send(None)
14901490
{
1491-
warn!("unexpected error telling logger thread to exit: {}", e);
1491+
warn!("unexpected error telling logger thread to exit: {e}");
14921492
};
14931493
// Take logger out of the GooseAttackRunState object so it can be
14941494
// consumed by tokio::join!().
@@ -1604,7 +1604,7 @@ impl GooseAttack {
16041604
} else {
16051605
Duration::from_millis(goose_attack_run_state.adjust_user_in_ms as u64)
16061606
};
1607-
debug!("sleeping {:?}...", sleep_duration);
1607+
debug!("sleeping {sleep_duration:?}...");
16081608
goose_attack_run_state.drift_timer =
16091609
util::sleep_minus_drift(sleep_duration, goose_attack_run_state.drift_timer)
16101610
.await;
@@ -1740,7 +1740,7 @@ impl GooseAttack {
17401740
// Sleep then check for further instructions.
17411741
if goose_attack_run_state.idle_status_displayed {
17421742
let sleep_duration = Duration::from_millis(250);
1743-
debug!("sleeping {:?}...", sleep_duration);
1743+
debug!("sleeping {sleep_duration:?}...");
17441744
goose_attack_run_state.drift_timer = util::sleep_minus_drift(
17451745
sleep_duration,
17461746
goose_attack_run_state.drift_timer,
@@ -1853,10 +1853,7 @@ fn allocate_transactions(
18531853
WeightedTransactions,
18541854
WeightedTransactions,
18551855
) {
1856-
debug!(
1857-
"allocating Transactions on GooseUsers with {:?} scheduler",
1858-
scheduler
1859-
);
1856+
debug!("allocating Transactions on GooseUsers with {scheduler:?} scheduler");
18601857

18611858
// A BTreeMap of Vectors allows us to group and sort transactions per sequence value.
18621859
let mut sequenced_transactions: SequencedTransactions = BTreeMap::new();

src/logger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ impl GooseConfiguration {
735735
} else {
736736
match File::create(log_file_path).await {
737737
Ok(f) => {
738-
info!("writing {} to: {}", log_file_type, log_file_path);
738+
info!("writing {log_file_type} to: {log_file_path}");
739739
Some(BufWriter::with_capacity(buffer_capacity, f))
740740
}
741741
Err(e) => {

src/metrics.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -513,17 +513,17 @@ impl GooseRequestMetricAggregate {
513513
let counter = match self.status_code_counts.get(&status_code) {
514514
// We've seen this status code before, increment counter.
515515
Some(c) => {
516-
debug!("got {:?} counter: {}", status_code, c);
516+
debug!("got {status_code:?} counter: {c}");
517517
*c + 1
518518
}
519519
// First time we've seen this status code, initialize counter.
520520
None => {
521-
debug!("no match for counter: {}", status_code);
521+
debug!("no match for counter: {status_code}");
522522
1
523523
}
524524
};
525525
self.status_code_counts.insert(status_code, counter);
526-
debug!("incremented {} counter: {}", status_code, counter);
526+
debug!("incremented {status_code} counter: {counter}");
527527
}
528528
}
529529

@@ -640,16 +640,16 @@ impl GooseRequestMetricTimingData {
640640
let counter = match self.times.get(&rounded_time) {
641641
// We've seen this elapsed time before, increment counter.
642642
Some(c) => {
643-
debug!("got {:?} counter: {}", rounded_time, c);
643+
debug!("got {rounded_time:?} counter: {c}");
644644
*c + 1
645645
}
646646
// First time we've seen this elapsed time, initialize counter.
647647
None => {
648-
debug!("no match for counter: {}", rounded_time);
648+
debug!("no match for counter: {rounded_time}");
649649
1
650650
}
651651
};
652-
debug!("incremented {} counter: {}", rounded_time, counter);
652+
debug!("incremented {rounded_time} counter: {counter}");
653653
self.times.insert(rounded_time, counter);
654654
}
655655
}
@@ -833,7 +833,7 @@ impl TransactionMetricAggregate {
833833
None => 1,
834834
};
835835
self.times.insert(rounded_time, counter);
836-
debug!("incremented {} counter: {}", rounded_time, counter);
836+
debug!("incremented {rounded_time} counter: {counter}");
837837
}
838838
}
839839
/// Aggregated per-scenario metrics updated each time a scenario is run.
@@ -920,7 +920,7 @@ impl ScenarioMetricAggregate {
920920
None => 1,
921921
};
922922
self.times.insert(rounded_time, counter);
923-
debug!("incremented {} counter: {}", rounded_time, counter);
923+
debug!("incremented {rounded_time} counter: {counter}");
924924
}
925925
}
926926
/// All metrics optionally collected during a Goose load test.
@@ -2960,9 +2960,9 @@ impl GooseAttack {
29602960
error: raw_request.error.clone(),
29612961
}))) {
29622962
if let flume::SendError(Some(ref message)) = e {
2963-
info!("Failed to write to error log (receiver dropped?): flume::SendError({:?})", message);
2963+
info!("Failed to write to error log (receiver dropped?): flume::SendError({message:?})");
29642964
} else {
2965-
info!("Failed to write to error log: (receiver dropped?) {:?}", e);
2965+
info!("Failed to write to error log: (receiver dropped?) {e:?}");
29662966
}
29672967
}
29682968
}
@@ -3408,10 +3408,7 @@ pub(crate) fn calculate_response_time_percentile(
34083408
percent: f32,
34093409
) -> usize {
34103410
let percentile_request = (total_requests as f32 * percent).round() as usize;
3411-
debug!(
3412-
"percentile: {}, request {} of total {}",
3413-
percent, percentile_request, total_requests
3414-
);
3411+
debug!("percentile: {percent}, request {percentile_request} of total {total_requests}");
34153412

34163413
let mut total_count: usize = 0;
34173414

src/throttle.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ pub async fn throttle_main(
1919
let tokens_per_duration;
2020

2121
let ten_milliseconds = time::Duration::from_millis(10);
22-
debug!(
23-
"sleep_duration: {:?} ten_milliseconds: {:?}",
24-
sleep_duration, ten_milliseconds
25-
);
22+
debug!("sleep_duration: {sleep_duration:?} ten_milliseconds: {ten_milliseconds:?}");
2623

2724
// Keep sleep_duration at least ~10ms as `delay_for` has millisecond granularity.
2825
if sleep_duration < ten_milliseconds {
@@ -32,10 +29,7 @@ pub async fn throttle_main(
3229
tokens_per_duration = 1;
3330
}
3431

35-
info!(
36-
"throttle allowing {} request(s) every {:?}",
37-
tokens_per_duration, sleep_duration
38-
);
32+
info!("throttle allowing {tokens_per_duration} request(s) every {sleep_duration:?}");
3933

4034
// One or more token gets removed from the throttle_receiver bucket at regular
4135
// intervals. The throttle_drift variable tracks how much time is spent on
@@ -44,10 +38,7 @@ pub async fn throttle_main(
4438

4539
// Loop and remove tokens from channel at controlled rate until load test ends.
4640
loop {
47-
debug!(
48-
"throttle removing {} token(s) from channel",
49-
tokens_per_duration
50-
);
41+
debug!("throttle removing {tokens_per_duration} token(s) from channel");
5142
throttle_drift = util::sleep_minus_drift(sleep_duration, throttle_drift).await;
5243

5344
// A message will be received when the load test is over.
@@ -62,7 +53,7 @@ pub async fn throttle_main(
6253
for token in 0..tokens_per_duration {
6354
// If the channel is empty, we will get an error, so stop trying to remove tokens.
6455
if throttle_receiver.try_recv().is_err() {
65-
debug!("empty channel, exit after removing {} tokens", token);
56+
debug!("empty channel, exit after removing {token} tokens");
6657
break;
6758
}
6859
}

src/user.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ fn received_exit(thread_receiver: &flume::Receiver<GooseUserCommand>) -> bool {
184184
return true;
185185
}
186186
command => {
187-
debug!("ignoring unexpected GooseUserCommand: {:?}", command);
187+
debug!("ignoring unexpected GooseUserCommand: {command:?}");
188188
}
189189
}
190190
message = thread_receiver.try_recv();

src/util.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub fn parse_timespan(time_str: &str) -> usize {
3434
match usize::from_str(time_str) {
3535
// If an integer is passed in, assume it's seconds
3636
Ok(t) => {
37-
trace!("{} is integer: {} seconds", time_str, t);
37+
trace!("{time_str} is integer: {t} seconds");
3838
t
3939
}
4040
// Otherwise use a regex to extract hours, minutes and seconds from string.
@@ -55,13 +55,7 @@ pub fn parse_timespan(time_str: &str) -> usize {
5555
None => 0,
5656
};
5757
let total = hours * 60 * 60 + minutes * 60 + seconds;
58-
trace!(
59-
"{} hours {} minutes {} seconds: {} seconds",
60-
hours,
61-
minutes,
62-
seconds,
63-
total
64-
);
58+
trace!("{hours} hours {minutes} minutes {seconds} seconds: {total} seconds");
6559
total
6660
}
6761
}
@@ -383,7 +377,7 @@ pub fn get_float_from_string(string: Option<String>) -> Option<f32> {
383377
Some(s) => match s.parse::<f32>() {
384378
Ok(value) => Some(value),
385379
Err(e) => {
386-
warn!("failed to convert {} to float: {}", s, e);
380+
warn!("failed to convert {s} to float: {e}");
387381
None
388382
}
389383
},
@@ -438,7 +432,7 @@ pub(crate) fn setup_ctrlc_handler() {
438432
// of the ctrl-c handler.
439433
let mut canceled = CANCELED.write().unwrap();
440434
*canceled = false;
441-
info!("reset ctrl-c handler: {}", e);
435+
info!("reset ctrl-c handler: {e}");
442436
}
443437
}
444438
}

0 commit comments

Comments
 (0)