Skip to content

Commit 1fe13b3

Browse files
Fix all clippy warnings — CI should pass now
- Collapse nested if-let blocks (collapsible_if) - Use std::slice::from_ref instead of clone-to-slice - Add type alias for complex browser function type - Suppress dead_code for deserialization-only fields
1 parent b0bb5b7 commit 1fe13b3

6 files changed

Lines changed: 31 additions & 23 deletions

File tree

src/api/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ impl SunoClient {
7070

7171
fn headers(&self) -> reqwest::header::HeaderMap {
7272
let mut headers = reqwest::header::HeaderMap::new();
73-
if let Ok(jwt) = self.auth.jwt() {
74-
if let Ok(val) = format!("Bearer {jwt}").parse() {
75-
headers.insert("authorization", val);
76-
}
73+
if let Ok(jwt) = self.auth.jwt()
74+
&& let Ok(val) = format!("Bearer {jwt}").parse()
75+
{
76+
headers.insert("authorization", val);
7777
}
7878
if let Ok(val) = self.auth.device_id().parse() {
7979
headers.insert("device-id", val);

src/api/persona.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,17 @@ impl SunoClient {
1414
.await?;
1515
let resp = self.check_response(resp).await?;
1616

17-
// The response may be the persona directly or wrapped in a paginated envelope.
18-
// Try direct parse first, fall back to extracting from items array.
1917
let body: serde_json::Value = resp.json().await?;
2018

21-
if let Some(items) = body.get("items").and_then(|v| v.as_array()) {
22-
if let Some(first) = items.first() {
23-
let info: PersonaInfo = serde_json::from_value(first.clone())?;
24-
return Ok(info);
25-
}
19+
if let Some(first) = body
20+
.get("items")
21+
.and_then(|v| v.as_array())
22+
.and_then(|items| items.first())
23+
{
24+
let info: PersonaInfo = serde_json::from_value(first.clone())?;
25+
return Ok(info);
2626
}
2727

28-
// Try parsing the entire response as PersonaInfo
2928
let info: PersonaInfo = serde_json::from_value(body)?;
3029
Ok(info)
3130
}

src/api/types.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ pub struct ClipMetadata {
103103
pub struct FeedResponse {
104104
#[serde(default)]
105105
pub clips: Vec<Clip>,
106+
#[allow(dead_code)]
106107
pub next_cursor: Option<String>,
107108
#[serde(default)]
109+
#[allow(dead_code)]
108110
pub has_more: bool,
109111
}
110112

@@ -196,6 +198,7 @@ pub struct ControlSliders {
196198
pub struct GenerateResponse {
197199
#[serde(default)]
198200
pub clips: Vec<Clip>,
201+
#[allow(dead_code)]
199202
pub status: Option<String>,
200203
}
201204

@@ -232,6 +235,7 @@ pub struct AlignedWord {
232235

233236
// --- Captcha Check ---
234237

238+
#[allow(dead_code)]
235239
#[derive(Debug, Deserialize)]
236240
pub struct CaptchaCheckResponse {
237241
#[serde(default)]
@@ -272,6 +276,7 @@ pub struct ConcatRequest {
272276

273277
// --- Persona ---
274278

279+
#[allow(dead_code)]
275280
#[derive(Debug, Deserialize, Serialize)]
276281
pub struct PersonaResponse {
277282
#[serde(default)]

src/auth.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ pub fn extract_clerk_cookie() -> Result<String, CliError> {
107107
let domains = Some(vec!["auth.suno.com".to_string(), ".suno.com".to_string()]);
108108

109109
// Each closure calls a different browser extractor
110-
let browsers: &[(&str, &dyn Fn() -> eyre::Result<Vec<rookie::enums::Cookie>>)] = &[
110+
type BrowserFn = dyn Fn() -> eyre::Result<Vec<rookie::enums::Cookie>>;
111+
let browsers: &[(&str, &BrowserFn)] = &[
111112
("Chrome", &|| {
112113
rookie::chrome(Some(vec!["auth.suno.com".into(), ".suno.com".into()]))
113114
}),

src/cli.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ pub enum VariationCategory {
485485
}
486486

487487
impl VariationCategory {
488+
#[allow(dead_code)]
488489
pub fn to_api_value(&self) -> &'static str {
489490
match self {
490491
Self::High => "high",

src/main.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,14 @@ async fn run() -> Result<(), CliError> {
228228
let c = client().await?;
229229

230230
// Check captcha before generating
231-
if let Ok(captcha_needed) = c.check_captcha().await {
232-
if captcha_needed && args.token.is_none() {
233-
eprintln!(
234-
"Warning: captcha required. Use --token <hcaptcha_token> or solve captcha in browser."
235-
);
236-
eprintln!(
237-
"Tip: Premier accounts with 200+ credits consumed usually skip captcha."
238-
);
239-
}
231+
if let Ok(captcha_needed) = c.check_captcha().await
232+
&& captcha_needed
233+
&& args.token.is_none()
234+
{
235+
eprintln!(
236+
"Warning: captcha required. Use --token <hcaptcha_token> or solve captcha in browser."
237+
);
238+
eprintln!("Tip: Premier accounts with 200+ credits consumed usually skip captcha.");
240239
}
241240

242241
// If persona specified, use task="vox"
@@ -408,7 +407,10 @@ async fn run() -> Result<(), CliError> {
408407
}
409408

410409
Commands::Info(args) => {
411-
let clips = client().await?.get_clips(&[args.id.clone()]).await?;
410+
let clips = client()
411+
.await?
412+
.get_clips(std::slice::from_ref(&args.id))
413+
.await?;
412414
if clips.is_empty() {
413415
return Err(CliError::NotFound(format!("clip: {}", args.id)));
414416
}

0 commit comments

Comments
 (0)