Skip to content

Commit

Permalink
chore: make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
ctron committed Jul 30, 2024
1 parent a6d8fc5 commit 1897ca7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
24 changes: 8 additions & 16 deletions src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ use tokio_tungstenite::tungstenite::Message;
/// - Commands will be displayed in the help screen in the order defined here, so
/// they should be logically grouped.
/// 2. Add the new command to `ControllerCommand::details` and populate all
/// `ControllerCommandDetails`, using other commands as an implementation reference.
/// - The `regex` is used to identify the command, and optionally to extract a
/// value (for example see `Hatchrate` and `Users`)
/// - If additional validation is required beyond the regular expression, add
/// the necessary logic to `ControllerCommand::validate_value`.
/// `ControllerCommandDetails`, using other commands as an implementation reference.
/// - The `regex` is used to identify the command, and optionally to extract a
/// value (for example see `Hatchrate` and `Users`)
/// - If additional validation is required beyond the regular expression, add
/// the necessary logic to `ControllerCommand::validate_value`.
/// 3. Add any necessary parent process logic for the command to
/// `GooseAttack::handle_controller_requests` (also in this file).
/// `GooseAttack::handle_controller_requests` (also in this file).
/// 4. Add a test for the new command in tests/controller.rs.
#[derive(Clone, Debug, EnumIter, PartialEq, Eq)]
pub enum ControllerCommand {
Expand Down Expand Up @@ -642,10 +642,8 @@ impl GooseAttack {
AttackPhase::Idle => {
let current_users = if !self.test_plan.steps.is_empty() {
self.test_plan.steps[self.test_plan.current].0
} else if let Some(users) = self.configuration.users {
users
} else {
0
self.configuration.users.unwrap_or_default()
};
info!(
"changing users from {:?} to {}",
Expand Down Expand Up @@ -1410,13 +1408,7 @@ impl Controller<ControllerTelnetMessage> for ControllerState {
raw_value: ControllerTelnetMessage,
) -> Result<String, String> {
let command_string = match str::from_utf8(&raw_value) {
Ok(m) => {
if let Some(c) = m.lines().next() {
c
} else {
""
}
}
Ok(m) => m.lines().next().unwrap_or_default(),
Err(e) => {
let error = format!("ignoring unexpected input from telnet controller: {}", e);
info!("{}", error);
Expand Down
12 changes: 6 additions & 6 deletions src/goose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ impl Scenario {
Scenario {
name: name.to_string(),
machine_name: Scenario::get_machine_name(name),
scenarios_index: usize::max_value(),
scenarios_index: usize::MAX,
weight: 1,
transaction_wait: None,
transactions: Vec::new(),
Expand Down Expand Up @@ -961,7 +961,7 @@ impl GooseUser {
metrics_channel: None,
shutdown_channel: None,
// A value of max_value() indicates this user isn't fully initialized yet.
weighted_users_index: usize::max_value(),
weighted_users_index: usize::MAX,
load_test_hash,
request_cadence: GooseRequestCadence::new(),
slept: 0,
Expand Down Expand Up @@ -1144,9 +1144,9 @@ impl GooseUser {
/// of precedence:
/// 1. `--host` (host specified on the command line when running load test)
/// 2. [`Scenario`](./struct.Scenario.html)`.host` (default host defined for the
/// current scenario)
/// current scenario)
/// 3. [`GooseDefault::Host`](../config/enum.GooseDefault.html#variant.Host) (default host
/// defined for the current load test)
/// defined for the current load test)
pub fn build_url(&self, path: &str) -> Result<String, Box<TransactionError>> {
// If URL includes a host, simply use it.
if let Ok(parsed_path) = Url::parse(path) {
Expand Down Expand Up @@ -2177,7 +2177,7 @@ impl GooseUser {
/// - A manually built client is specific to a single Goose thread -- if you are
/// generating a large load test with many users, each will need to manually build their
/// own client (typically you'd do this in a Transaction that is registered with
/// [`Transaction::set_on_start()`] in each Scenario requiring a custom client;
/// [`Transaction::set_on_start()`] in each Scenario requiring a custom client;
/// - Manually building a client will completely replace the automatically built client
/// with a brand new one, so any configuration, cookies or headers set in the previously
/// built client will be gone;
Expand Down Expand Up @@ -2811,7 +2811,7 @@ impl Transaction {
pub fn new(function: TransactionFunction) -> Self {
trace!("new transaction");
Transaction {
transactions_index: usize::max_value(),
transactions_index: usize::MAX,
name: "".to_string(),
weight: 1,
sequence: 0,
Expand Down

0 comments on commit 1897ca7

Please sign in to comment.