Skip to content

Commit 8fbe553

Browse files
committed
chore: linter fixes
1 parent 68e1841 commit 8fbe553

File tree

14 files changed

+201
-203
lines changed

14 files changed

+201
-203
lines changed

src/client/auth.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ impl OAuthFlow {
128128
.expires_in()
129129
.map(|d| chrono::Utc::now() + chrono::Duration::seconds(d.as_secs() as i64));
130130

131-
if let Some(refresh) = refresh_token {
132-
if let Some(expires) = expires_at {
133-
return Ok(Credentials::with_refresh(access_token, refresh, expires));
134-
}
131+
if let Some(refresh) = refresh_token
132+
&& let Some(expires) = expires_at
133+
{
134+
return Ok(Credentials::with_refresh(access_token, refresh, expires));
135135
}
136136

137137
Ok(Credentials::new(access_token))

src/commands/dev/reset.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,10 @@ fn redeploy_applications(deploy_dir: &std::path::Path) {
219219
"-o",
220220
"jsonpath={.status.readyReplicas}",
221221
],
222-
) {
223-
if output.trim() == "1" {
224-
ready = true;
225-
break;
226-
}
222+
) && output.trim() == "1"
223+
{
224+
ready = true;
225+
break;
227226
}
228227
std::thread::sleep(Duration::from_secs(2));
229228
}

src/commands/dev/start.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ pub async fn start(
5353
commit: Option<&str>,
5454
) -> Result<()> {
5555
// Save CLI-provided credentials if both are present
56-
if let (Some(client_id), Some(client_secret)) = (&tailscale_client, &tailscale_secret) {
57-
if !client_id.is_empty() && !client_secret.is_empty() {
58-
save_tailscale_credentials(client_id, client_secret)?;
59-
}
56+
if let (Some(client_id), Some(client_secret)) = (&tailscale_client, &tailscale_secret)
57+
&& !client_id.is_empty()
58+
&& !client_secret.is_empty()
59+
{
60+
save_tailscale_credentials(client_id, client_secret)?;
6061
}
6162

6263
// For new cluster creation, use interactive mode if requested
@@ -854,10 +855,10 @@ fn start_with_streaming(skip_build: bool, force: bool, commit: Option<&str>) ->
854855
)?;
855856

856857
run_step(&StartStep::with_ok("Setting kubectl context", "Set kubectl context"), || {
857-
if let Some(current) = kubectl_current_context() {
858-
if current == KUBE_CONTEXT {
859-
return Ok(StepOutcome::Skipped);
860-
}
858+
if let Some(current) = kubectl_current_context()
859+
&& current == KUBE_CONTEXT
860+
{
861+
return Ok(StepOutcome::Skipped);
861862
}
862863
kubectl_use_context(KUBE_CONTEXT).map(|()| StepOutcome::Success)
863864
})?;

src/commands/dev/status.rs

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -123,31 +123,29 @@ fn print_nodes_status() {
123123
let red = Color::Red.to_ansi_fg();
124124
let reset = RESET;
125125

126-
if let Some(output) = output {
127-
if let Ok(json) = serde_json::from_str::<serde_json::Value>(&output) {
128-
if let Some(items) = json["items"].as_array() {
129-
for node in items {
130-
let name = node["metadata"]["name"].as_str().unwrap_or("");
131-
let labels = &node["metadata"]["labels"];
132-
let is_control_plane =
133-
labels.get("node-role.kubernetes.io/control-plane").is_some();
134-
135-
let ready = node["status"]["conditions"]
136-
.as_array()
137-
.and_then(|conditions| conditions.iter().find(|c| c["type"] == "Ready"))
138-
.is_some_and(|c| c["status"] == "True");
139-
140-
let role = if is_control_plane { "control-plane" } else { "worker" };
141-
let status = if ready {
142-
format!("{green}Ready{reset} ({role})")
143-
} else {
144-
format!("{red}NotReady{reset} ({role})")
145-
};
146-
147-
let display_name = name.strip_prefix("inferadb-dev-").unwrap_or(name);
148-
print_prefixed_dot_leader(" ", display_name, &status);
149-
}
150-
}
126+
if let Some(output) = output
127+
&& let Ok(json) = serde_json::from_str::<serde_json::Value>(&output)
128+
&& let Some(items) = json["items"].as_array()
129+
{
130+
for node in items {
131+
let name = node["metadata"]["name"].as_str().unwrap_or("");
132+
let labels = &node["metadata"]["labels"];
133+
let is_control_plane = labels.get("node-role.kubernetes.io/control-plane").is_some();
134+
135+
let ready = node["status"]["conditions"]
136+
.as_array()
137+
.and_then(|conditions| conditions.iter().find(|c| c["type"] == "Ready"))
138+
.is_some_and(|c| c["status"] == "True");
139+
140+
let role = if is_control_plane { "control-plane" } else { "worker" };
141+
let status = if ready {
142+
format!("{green}Ready{reset} ({role})")
143+
} else {
144+
format!("{red}NotReady{reset} ({role})")
145+
};
146+
147+
let display_name = name.strip_prefix("inferadb-dev-").unwrap_or(name);
148+
print_prefixed_dot_leader(" ", display_name, &status);
151149
}
152150
}
153151
}
@@ -216,10 +214,10 @@ fn print_pods_status() {
216214

217215
if let Some(output) = inferadb_pods {
218216
for line in output.lines() {
219-
if let Some((name, status)) = format_pod(line) {
220-
if seen_names.insert(name.clone()) {
221-
print_prefixed_dot_leader(" ", &name, &status);
222-
}
217+
if let Some((name, status)) = format_pod(line)
218+
&& seen_names.insert(name.clone())
219+
{
220+
print_prefixed_dot_leader(" ", &name, &status);
223221
}
224222
}
225223
}

src/commands/dev/stop.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -339,24 +339,24 @@ fn cleanup_tailscale_devices() -> Result<()> {
339339
.map_err(|e| Error::Other(e.to_string()))?;
340340

341341
let response = String::from_utf8_lossy(&output.stdout);
342-
if let Ok(json) = serde_json::from_str::<serde_json::Value>(&response) {
343-
if let Some(devices) = json.get("devices").and_then(|d| d.as_array()) {
344-
for device in devices {
345-
let name = device.get("hostname").and_then(|n| n.as_str()).unwrap_or("");
346-
let id = device.get("id").and_then(|i| i.as_str()).unwrap_or("");
347-
348-
if name.starts_with(TAILSCALE_DEVICE_PREFIX) && !id.is_empty() {
349-
let _ = Command::new("curl")
350-
.args([
351-
"-s",
352-
"-X",
353-
"DELETE",
354-
"-H",
355-
&format!("Authorization: Bearer {token}"),
356-
&format!("https://api.tailscale.com/api/v2/device/{id}"),
357-
])
358-
.output();
359-
}
342+
if let Ok(json) = serde_json::from_str::<serde_json::Value>(&response)
343+
&& let Some(devices) = json.get("devices").and_then(|d| d.as_array())
344+
{
345+
for device in devices {
346+
let name = device.get("hostname").and_then(|n| n.as_str()).unwrap_or("");
347+
let id = device.get("id").and_then(|i| i.as_str()).unwrap_or("");
348+
349+
if name.starts_with(TAILSCALE_DEVICE_PREFIX) && !id.is_empty() {
350+
let _ = Command::new("curl")
351+
.args([
352+
"-s",
353+
"-X",
354+
"DELETE",
355+
"-H",
356+
&format!("Authorization: Bearer {token}"),
357+
&format!("https://api.tailscale.com/api/v2/device/{id}"),
358+
])
359+
.output();
360360
}
361361
}
362362
}

src/commands/dev/tailscale.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ pub fn get_tailscale_credentials() -> Result<(String, String)> {
7474
// Try environment variables first
7575
if let (Ok(id), Ok(secret)) =
7676
(env::var("TAILSCALE_CLIENT_ID"), env::var("TAILSCALE_CLIENT_SECRET"))
77+
&& !id.is_empty()
78+
&& !secret.is_empty()
7779
{
78-
if !id.is_empty() && !secret.is_empty() {
79-
return Ok((id, secret));
80-
}
80+
return Ok((id, secret));
8181
}
8282

8383
// Try cached credentials

src/commands/identity.rs

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,10 @@ async fn show_health(ctx: &Context, verbose: bool) -> Result<()> {
289289
println!("Status: ✓ healthy");
290290
println!("Latency: {}ms", start.elapsed().as_millis());
291291

292-
if verbose {
293-
if let Ok(body) = resp.text().await {
294-
println!();
295-
println!("Response:");
296-
println!("{body}");
297-
}
292+
if verbose && let Ok(body) = resp.text().await {
293+
println!();
294+
println!("Response:");
295+
println!("{body}");
298296
}
299297
},
300298
Ok(resp) => {
@@ -522,17 +520,17 @@ pub async fn what_changed(
522520
if log.timestamp < since_time {
523521
return false;
524522
}
525-
if let Some(ref ut) = until_time {
526-
if log.timestamp > *ut {
527-
return false;
528-
}
523+
if let Some(ref ut) = until_time
524+
&& log.timestamp > *ut
525+
{
526+
return false;
529527
}
530528

531529
// Actor filter
532-
if let Some(a) = actor {
533-
if !log.actor.id.contains(a) {
534-
return false;
535-
}
530+
if let Some(a) = actor
531+
&& !log.actor.id.contains(a)
532+
{
533+
return false;
536534
}
537535

538536
// Resource filter
@@ -1202,25 +1200,25 @@ fn parse_time_spec(spec: &str) -> chrono::DateTime<chrono::Utc> {
12021200
"today" => now - Duration::hours(i64::from(now.hour())),
12031201
_ => {
12041202
// Try parsing as duration like "1h", "1d", "30m"
1205-
if let Some(stripped) = spec.strip_suffix('h') {
1206-
if let Ok(hours) = stripped.parse::<i64>() {
1207-
return now - Duration::hours(hours);
1208-
}
1203+
if let Some(stripped) = spec.strip_suffix('h')
1204+
&& let Ok(hours) = stripped.parse::<i64>()
1205+
{
1206+
return now - Duration::hours(hours);
12091207
}
1210-
if let Some(stripped) = spec.strip_suffix('d') {
1211-
if let Ok(days) = stripped.parse::<i64>() {
1212-
return now - Duration::days(days);
1213-
}
1208+
if let Some(stripped) = spec.strip_suffix('d')
1209+
&& let Ok(days) = stripped.parse::<i64>()
1210+
{
1211+
return now - Duration::days(days);
12141212
}
1215-
if let Some(stripped) = spec.strip_suffix('m') {
1216-
if let Ok(mins) = stripped.parse::<i64>() {
1217-
return now - Duration::minutes(mins);
1218-
}
1213+
if let Some(stripped) = spec.strip_suffix('m')
1214+
&& let Ok(mins) = stripped.parse::<i64>()
1215+
{
1216+
return now - Duration::minutes(mins);
12191217
}
1220-
if let Some(stripped) = spec.strip_suffix('w') {
1221-
if let Ok(weeks) = stripped.parse::<i64>() {
1222-
return now - Duration::weeks(weeks);
1223-
}
1218+
if let Some(stripped) = spec.strip_suffix('w')
1219+
&& let Ok(weeks) = stripped.parse::<i64>()
1220+
{
1221+
return now - Duration::weeks(weeks);
12241222
}
12251223

12261224
// Default to 1 day ago

src/commands/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,8 @@ async fn cheatsheet(_ctx: &Context, _role: Option<&str>) -> Result<()> {
596596
Ok(())
597597
}
598598

599-
fn print_completions<G: clap_complete::Generator>(gen: G, cmd: &mut clap::Command) {
600-
clap_complete::generate(gen, cmd, cmd.get_name().to_string(), &mut std::io::stdout());
599+
fn print_completions<G: clap_complete::Generator>(generator: G, cmd: &mut clap::Command) {
600+
clap_complete::generate(generator, cmd, cmd.get_name().to_string(), &mut std::io::stdout());
601601
}
602602

603603
async fn completion(_ctx: &Context, shell: &crate::cli::Shell) -> Result<()> {

src/commands/tokens.rs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -78,25 +78,24 @@ pub async fn list(ctx: &Context) -> Result<()> {
7878
}
7979

8080
// Also check "default" if not in profiles
81-
if !ctx.config.profiles.contains_key("default") {
82-
if let Ok(Some(creds)) = store.load("default") {
83-
let status = if creds.is_expired() {
84-
"expired".to_string()
85-
} else if creds.expires_soon() {
86-
"expires soon".to_string()
87-
} else {
88-
"valid".to_string()
89-
};
81+
if !ctx.config.profiles.contains_key("default")
82+
&& let Ok(Some(creds)) = store.load("default")
83+
{
84+
let status = if creds.is_expired() {
85+
"expired".to_string()
86+
} else if creds.expires_soon() {
87+
"expires soon".to_string()
88+
} else {
89+
"valid".to_string()
90+
};
9091

91-
let expires = creds.expires_at.map_or_else(
92-
|| "unknown".to_string(),
93-
|dt| dt.format("%Y-%m-%d %H:%M").to_string(),
94-
);
92+
let expires = creds
93+
.expires_at
94+
.map_or_else(|| "unknown".to_string(), |dt| dt.format("%Y-%m-%d %H:%M").to_string());
9595

96-
let can_refresh = if creds.can_refresh() { "yes" } else { "no" }.to_string();
96+
let can_refresh = if creds.can_refresh() { "yes" } else { "no" }.to_string();
9797

98-
rows.push(TokenRow { profile: "default".to_string(), status, expires, can_refresh });
99-
}
98+
rows.push(TokenRow { profile: "default".to_string(), status, expires, can_refresh });
10099
}
101100

102101
if rows.is_empty() {
@@ -223,10 +222,10 @@ pub async fn inspect(ctx: &Context, token: Option<&str>, verify: bool) -> Result
223222
}
224223

225224
// Show issued at
226-
if let Some(iat) = payload.get("iat").and_then(serde_json::Value::as_i64) {
227-
if let Some(dt) = chrono::DateTime::from_timestamp(iat, 0) {
228-
println!("Issued: {}", dt.format("%Y-%m-%d %H:%M:%S UTC"));
229-
}
225+
if let Some(iat) = payload.get("iat").and_then(serde_json::Value::as_i64)
226+
&& let Some(dt) = chrono::DateTime::from_timestamp(iat, 0)
227+
{
228+
println!("Issued: {}", dt.format("%Y-%m-%d %H:%M:%S UTC"));
230229
}
231230
},
232231
Err(e) => {

0 commit comments

Comments
 (0)