Skip to content
This repository was archived by the owner on Jan 27, 2026. It is now read-only.

Commit 44817f3

Browse files
authored
fix clippy match_same_arms warnings (#599)
1 parent 0ad0e5c commit 44817f3

12 files changed

Lines changed: 51 additions & 37 deletions

File tree

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,8 @@ edition = "2021"
4646
[workspace.features]
4747
default = []
4848
testnet = []
49+
50+
[workspace.lints.clippy]
51+
match_same_arms = "warn"
52+
unused_async = "warn"
53+
uninlined_format_args = "warn"

crates/orchestrator/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ async fn main() -> Result<()> {
133133
"info" => LevelFilter::Info,
134134
"debug" => LevelFilter::Debug,
135135
"trace" => LevelFilter::Trace,
136-
_ => LevelFilter::Info, // Default to Info if the level is unrecognized
136+
_ => anyhow::bail!("invalid log level: {}", args.log_level),
137137
};
138138
env_logger::Builder::new()
139139
.filter_level(log_level)
@@ -146,10 +146,10 @@ async fn main() -> Result<()> {
146146
.init();
147147

148148
let server_mode = match args.mode.as_str() {
149-
"full" => ServerMode::Full,
150149
"api" => ServerMode::ApiOnly,
151150
"processor" => ServerMode::ProcessorOnly,
152-
_ => ServerMode::Full,
151+
"full" => ServerMode::Full,
152+
_ => anyhow::bail!("invalid server mode: {}", args.mode),
153153
};
154154

155155
debug!("Log level: {log_level}");

crates/orchestrator/src/plugins/node_groups/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ impl NodeGroupsPlugin {
627627
group.configuration_name.clone(),
628628
group.nodes.iter().cloned().collect(),
629629
) {
630-
error!("Failed to send group created webhook: {}", e);
630+
error!("Failed to send group created webhook: {e}");
631631
}
632632
}
633633
}
@@ -990,7 +990,7 @@ impl NodeGroupsPlugin {
990990
group.configuration_name.clone(),
991991
group.nodes.iter().cloned().collect(),
992992
) {
993-
error!("Failed to send group dissolved webhook: {}", e);
993+
error!("Failed to send group dissolved webhook: {e}");
994994
}
995995
}
996996
}
@@ -1002,7 +1002,7 @@ impl NodeGroupsPlugin {
10021002
merged_group.configuration_name.clone(),
10031003
merged_group.nodes.iter().cloned().collect(),
10041004
) {
1005-
error!("Failed to send group created webhook: {}", e);
1005+
error!("Failed to send group created webhook: {e}");
10061006
}
10071007
}
10081008
}
@@ -1081,7 +1081,7 @@ impl NodeGroupsPlugin {
10811081
group.configuration_name.clone(),
10821082
group.nodes.iter().cloned().collect(),
10831083
) {
1084-
error!("Failed to send group dissolved webhook: {}", e);
1084+
error!("Failed to send group dissolved webhook: {e}");
10851085
}
10861086
}
10871087
}

crates/orchestrator/src/store/domains/node_store.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ impl NodeStore {
192192
}
193193
}
194194

195+
#[allow(clippy::match_same_arms)]
195196
nodes.sort_by(|a, b| match (&a.status, &b.status) {
196197
(NodeStatus::Healthy, NodeStatus::Healthy) => std::cmp::Ordering::Equal,
197198
(NodeStatus::Healthy, _) => std::cmp::Ordering::Less,

crates/shared/src/models/task.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ impl From<&str> for TaskState {
3131
"FAILED" => TaskState::FAILED,
3232
"PAUSED" => TaskState::PAUSED,
3333
"RESTARTING" => TaskState::RESTARTING,
34-
"UNKNOWN" => TaskState::UNKNOWN,
35-
_ => TaskState::UNKNOWN, // Default case
34+
"UNKNOWN" | &_ => TaskState::UNKNOWN,
3635
}
3736
}
3837
}

crates/validator/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,15 @@ struct Args {
204204
}
205205

206206
#[tokio::main]
207-
async fn main() -> Result<(), Box<dyn std::error::Error>> {
207+
async fn main() -> anyhow::Result<()> {
208208
let args = Args::parse();
209209
let log_level = match args.log_level.as_str() {
210210
"error" => LevelFilter::Error,
211211
"warn" => LevelFilter::Warn,
212212
"info" => LevelFilter::Info,
213213
"debug" => LevelFilter::Debug,
214214
"trace" => LevelFilter::Trace,
215-
_ => LevelFilter::Info,
215+
_ => anyhow::bail!("invalid log level: {}", args.log_level),
216216
};
217217
env_logger::Builder::new()
218218
.filter_level(log_level)

crates/validator/src/validators/synthetic_data/chain_operations.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl SyntheticDataValidator<WalletProvider> {
2929
.await?
3030
.ok_or_else(|| Error::msg("Work info not found for soft invalidation"))?;
3131
let work_key_bytes = hex::decode(work_key)
32-
.map_err(|e| Error::msg(format!("Failed to decode hex work key: {}", e)))?;
32+
.map_err(|e| Error::msg(format!("Failed to decode hex work key: {e}")))?;
3333

3434
// Create 64-byte payload: work_key (32 bytes) + work_units (32 bytes)
3535
let mut data = Vec::with_capacity(64);
@@ -46,8 +46,8 @@ impl SyntheticDataValidator<WalletProvider> {
4646
{
4747
Ok(_) => Ok(()),
4848
Err(e) => {
49-
error!("Failed to soft invalidate work {}: {}", work_key, e);
50-
Err(Error::msg(format!("Failed to soft invalidate work: {}", e)))
49+
error!("Failed to soft invalidate work {work_key}: {e}");
50+
Err(Error::msg(format!("Failed to soft invalidate work: {e}")))
5151
}
5252
}
5353
}
@@ -85,16 +85,16 @@ impl SyntheticDataValidator<WalletProvider> {
8585
}
8686

8787
let data = hex::decode(work_key)
88-
.map_err(|e| Error::msg(format!("Failed to decode hex work key: {}", e)))?;
88+
.map_err(|e| Error::msg(format!("Failed to decode hex work key: {e}")))?;
8989
match self
9090
.prime_network
9191
.invalidate_work(self.pool_id, self.penalty, data)
9292
.await
9393
{
9494
Ok(_) => Ok(()),
9595
Err(e) => {
96-
error!("Failed to invalidate work {}: {}", work_key, e);
97-
Err(Error::msg(format!("Failed to invalidate work: {}", e)))
96+
error!("Failed to invalidate work {work_key}: {e}");
97+
Err(Error::msg(format!("Failed to invalidate work: {e}")))
9898
}
9999
}
100100
}

crates/worker/src/checks/issue.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ pub enum IssueType {
2424
impl IssueType {
2525
pub const fn severity(&self) -> Severity {
2626
match self {
27-
Self::NetworkConnectivityIssue => Severity::Warning,
28-
Self::InsufficientCpu => Severity::Warning,
29-
Self::InsufficientMemory => Severity::Warning,
30-
Self::InsufficientStorage => Severity::Warning,
31-
_ => Severity::Error,
27+
Self::NetworkConnectivityIssue
28+
| Self::InsufficientCpu
29+
| Self::InsufficientMemory
30+
| Self::InsufficientStorage => Severity::Warning,
31+
Self::NoGpu
32+
| Self::DockerNotInstalled
33+
| Self::ContainerToolkitNotInstalled
34+
| Self::NoStoragePath
35+
| Self::PortUnavailable => Severity::Error,
3236
}
3337
}
3438
}

crates/worker/src/cli/command.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ pub async fn execute_command(
687687
};
688688

689689
if let Err(e) = p2p_service.start() {
690-
error!("❌ Failed to start P2P listener: {}", e);
690+
error!("❌ Failed to start P2P listener: {e}");
691691
std::process::exit(1);
692692
}
693693

crates/worker/src/docker/docker_manager.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,9 +784,10 @@ impl DockerManager {
784784
match log_result {
785785
Ok(log_output) => {
786786
let message_bytes = match log_output {
787-
LogOutput::StdOut { message } | LogOutput::StdErr { message } => message,
788-
LogOutput::Console { message } => message,
789-
LogOutput::StdIn { message } => message,
787+
LogOutput::StdOut { message }
788+
| LogOutput::StdErr { message }
789+
| LogOutput::Console { message }
790+
| LogOutput::StdIn { message } => message,
790791
};
791792

792793
// Strip ANSI escape sequences, skipping on error.

0 commit comments

Comments
 (0)