Skip to content

Commit 3223cf9

Browse files
committed
fix(clippy): address rust 1.95 clippy lints
CI uses rustc 1.95 which catches lints not present in 1.93. Apply suggested fixes: - map(...).unwrap_or(false) -> is_ok_and(...) - map(f).unwrap_or(default) -> map_or(default, f) - Drop unnecessary trailing commas in macro args - Replace manual is_some_and pattern with .is_ok_and(...) - Replace sort_by(|a,b| a.cmp(b)) with sort_by_key - Add module-level allow(result_large_err) on driver gRPC handlers that stream tonic::Status, mirroring openshell-server's grpc/* files.
1 parent e505b99 commit 3223cf9

35 files changed

Lines changed: 303 additions & 317 deletions

File tree

crates/openshell-bootstrap/src/docker.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -749,10 +749,7 @@ pub async fn ensure_container(
749749
// When OPENSHELL_PUSH_IMAGES is set the entrypoint overrides the baked-in
750750
// HelmChart manifest so k3s uses the locally-pushed images with
751751
// IfNotPresent pull policy instead of pulling from the remote registry.
752-
let push_mode = std::env::var("OPENSHELL_PUSH_IMAGES")
753-
.ok()
754-
.filter(|v| !v.trim().is_empty())
755-
.is_some();
752+
let push_mode = std::env::var("OPENSHELL_PUSH_IMAGES").is_ok_and(|v| !v.trim().is_empty());
756753
let effective_tag = std::env::var("IMAGE_TAG")
757754
.ok()
758755
.filter(|v| !v.trim().is_empty())

crates/openshell-cli/src/auth.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ pub async fn browser_auth_flow(gateway_endpoint: &str) -> Result<String> {
9494
// listener, spawns a callback server, and waits the full AUTH_TIMEOUT
9595
// (120 s) for a POST that will never arrive.
9696
let no_browser = std::env::var("OPENSHELL_NO_BROWSER")
97-
.map(|v| v == "1" || v.eq_ignore_ascii_case("true"))
98-
.unwrap_or(false);
97+
.is_ok_and(|v| v == "1" || v.eq_ignore_ascii_case("true"));
9998
if no_browser {
10099
return Err(miette::miette!(
101100
"authentication skipped (OPENSHELL_NO_BROWSER is set).\n\

crates/openshell-cli/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ fn resolve_sandbox_name(name: Option<String>, gateway: &str) -> Result<String> {
151151
Specify a sandbox name or connect to one first: nav sandbox connect <name>"
152152
)
153153
})?;
154-
eprintln!("{} Using sandbox '{}' (last used)", "→".bold(), last.bold(),);
154+
eprintln!("{} Using sandbox '{}' (last used)", "→".bold(), last.bold());
155155
Ok(last)
156156
}
157157

@@ -1869,7 +1869,7 @@ async fn main() -> Result<()> {
18691869
} else {
18701870
println!("{}", "Gateway Status".cyan().bold());
18711871
println!();
1872-
println!(" {} No gateway configured.", "Status:".dimmed(),);
1872+
println!(" {} No gateway configured.", "Status:".dimmed());
18731873
println!();
18741874
println!(
18751875
"Deploy a gateway with: {}",
@@ -1892,7 +1892,7 @@ async fn main() -> Result<()> {
18921892
eprintln!("→ Found forward on sandbox '{n}'");
18931893
n
18941894
} else {
1895-
eprintln!("{} No active forward found for port {port}", "!".yellow(),);
1895+
eprintln!("{} No active forward found for port {port}", "!".yellow());
18961896
return Ok(());
18971897
}
18981898
}

crates/openshell-cli/src/run.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,7 @@ const CLUSTER_DEPLOY_LOG_LINES: usize = 15;
429429

430430
/// Return the current terminal width, falling back to 80 columns.
431431
fn term_width() -> usize {
432-
crossterm::terminal::size()
433-
.map(|(w, _)| w as usize)
434-
.unwrap_or(80)
432+
crossterm::terminal::size().map_or(80, |(w, _)| w as usize)
435433
}
436434

437435
/// Build a horizontal rule of `─` characters with an optional centered label.
@@ -446,7 +444,7 @@ fn horizontal_rule(label: Option<&str>, width: usize) -> String {
446444
let remaining = width - text_len;
447445
let left = remaining / 2;
448446
let right = remaining - left;
449-
format!("{}{}{}", "─".repeat(left), text_with_pad, "─".repeat(right),)
447+
format!("{}{}{}", "─".repeat(left), text_with_pad, "─".repeat(right))
450448
}
451449
None => "─".repeat(width),
452450
}
@@ -1182,7 +1180,7 @@ pub async fn gateway_login(name: &str) -> Result<()> {
11821180
let token = crate::auth::browser_auth_flow(&metadata.gateway_endpoint).await?;
11831181
openshell_bootstrap::edge_token::store_edge_token(name, &token)?;
11841182

1185-
eprintln!("{} Authenticated to gateway '{name}'", "✓".green().bold(),);
1183+
eprintln!("{} Authenticated to gateway '{name}'", "✓".green().bold());
11861184

11871185
Ok(())
11881186
}
@@ -2446,7 +2444,7 @@ pub async fn sandbox_create(
24462444
)
24472445
.await?;
24482446
}
2449-
eprintln!(" {} Files uploaded", "\u{2713}".green().bold(),);
2447+
eprintln!(" {} Files uploaded", "\u{2713}".green().bold());
24502448
}
24512449

24522450
// If --forward was requested, start the background port forward
@@ -4594,7 +4592,7 @@ pub async fn gateway_setting_delete(
45944592
response.settings_revision
45954593
);
45964594
} else {
4597-
println!("{} Global setting {} not found", "!".yellow(), key,);
4595+
println!("{} Global setting {} not found", "!".yellow(), key);
45984596
}
45994597
Ok(())
46004598
}

crates/openshell-core/src/paths.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,7 @@ pub fn ensure_parent_dir_restricted(path: &Path) -> Result<()> {
105105
#[cfg(unix)]
106106
pub fn is_file_permissions_too_open(path: &Path) -> bool {
107107
use std::os::unix::fs::PermissionsExt;
108-
std::fs::metadata(path)
109-
.map(|m| m.permissions().mode() & 0o077 != 0)
110-
.unwrap_or(false)
108+
std::fs::metadata(path).is_ok_and(|m| m.permissions().mode() & 0o077 != 0)
111109
}
112110

113111
#[cfg(test)]

crates/openshell-driver-docker/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1606,7 +1606,7 @@ fn write_cache_binary_atomic(final_path: &Path, bytes: &[u8]) -> CoreResult<()>
16061606
))
16071607
})?;
16081608
temp.as_file().sync_all().map_err(|err| {
1609-
Error::config(format!("failed to sync supervisor binary temp file: {err}",))
1609+
Error::config(format!("failed to sync supervisor binary temp file: {err}"))
16101610
})?;
16111611

16121612
#[cfg(unix)]

crates/openshell-driver-kubernetes/src/grpc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4+
#![allow(clippy::result_large_err)] // gRPC handlers return Result<_, tonic::Status>
5+
46
use futures::{Stream, StreamExt};
57
use openshell_core::proto::compute::v1::{
68
CreateSandboxRequest, CreateSandboxResponse, DeleteSandboxRequest, DeleteSandboxResponse,

crates/openshell-driver-podman/src/config.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,13 @@ impl PodmanComputeConfig {
121121
}
122122
#[cfg(target_os = "linux")]
123123
{
124-
if let Ok(xdg) = std::env::var("XDG_RUNTIME_DIR") {
125-
PathBuf::from(xdg).join("podman/podman.sock")
126-
} else {
127-
let uid = nix::unistd::getuid();
128-
PathBuf::from(format!("/run/user/{uid}/podman/podman.sock"))
129-
}
124+
std::env::var("XDG_RUNTIME_DIR").map_or_else(
125+
|_| {
126+
let uid = nix::unistd::getuid();
127+
PathBuf::from(format!("/run/user/{uid}/podman/podman.sock"))
128+
},
129+
|xdg| PathBuf::from(xdg).join("podman/podman.sock"),
130+
)
130131
}
131132
}
132133
}

crates/openshell-driver-podman/src/grpc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4+
#![allow(clippy::result_large_err)] // gRPC handlers return Result<_, tonic::Status>
5+
46
use futures::{Stream, StreamExt};
57
use openshell_core::proto::compute::v1::{
68
CreateSandboxRequest, CreateSandboxResponse, DeleteSandboxRequest, DeleteSandboxResponse,

crates/openshell-driver-vm/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ fn main() {
111111
e
112112
)
113113
});
114-
let size = fs::metadata(&dst_path).map(|m| m.len()).unwrap_or(0);
114+
let size = fs::metadata(&dst_path).map_or(0, |m| m.len());
115115
println!("cargo:warning=Embedded {src_name}: {size} bytes");
116116
}
117117

0 commit comments

Comments
 (0)