Skip to content

Commit 0c38130

Browse files
committed
Fix clippy formatting issues
Since the latest Rust version, clippy raises warnings if the inline formatting syntax is not used
1 parent 85953b1 commit 0c38130

39 files changed

+85
-98
lines changed

src/cli/auth.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl Matcher for AuthSubCommand {
5757

5858
match response {
5959
Ok(_) => println!("Profile set successfully"),
60-
Err(e) => println!("Failed to set profile: {}", e),
60+
Err(e) => println!("Failed to set profile: {e}"),
6161
}
6262
}
6363
}
@@ -170,7 +170,7 @@ impl AuthProfile {
170170
/// # Implementation Details
171171
/// Uses "--" as a delimiter between URL and token since URLs cannot contain "--"
172172
fn combine_url_and_token(url: &str, token: &str) -> String {
173-
format!("{}--{}", url, token)
173+
format!("{url}--{token}")
174174
}
175175

176176
/// Splits a combined URL and token string back into separate components.

src/cli/base.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub fn evaluate_and_print_response<T: Serialize>(response: Result<Response<T>, S
3131
response.print_result();
3232
}
3333
Err(e) => {
34-
println!("Error: {}", e);
34+
println!("Error: {e}");
3535
}
3636
}
3737
}
@@ -56,10 +56,10 @@ where
5656
{
5757
let value = matches
5858
.get_one::<U>(arg_name)
59-
.unwrap_or_else(|| panic!("{} is required.", arg_name))
59+
.unwrap_or_else(|| panic!("{arg_name} is required."))
6060
.as_ref()
6161
.parse::<T>()
62-
.unwrap_or_else(|_| panic!("{} is invalid.", arg_name));
62+
.unwrap_or_else(|_| panic!("{arg_name} is invalid."));
6363

6464
value
6565
}

src/cli/dataset.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use std::fs::File;
1212
use std::io::Write;
1313
use std::path::{Path, PathBuf};
1414

15-
use chrono::ParseResult;
1615
use colored_json::Paint;
1716
use structopt::StructOpt;
1817
use tokio::runtime::Runtime;
@@ -386,7 +385,7 @@ impl Matcher for DatasetSubCommand {
386385

387386
let response = runtime.block_on(
388387
direct_upload::batch_direct_upload()
389-
.client(&client)
388+
.client(client)
390389
.id(id)
391390
.files(paths)
392391
.bodies(bodies)
@@ -431,7 +430,7 @@ impl Matcher for DatasetSubCommand {
431430
};
432431

433432
if let Err(e) = response {
434-
eprintln!("Error: {}", e);
433+
eprintln!("Error: {e}");
435434
}
436435
}
437436
DatasetSubCommand::Export {
@@ -451,7 +450,7 @@ impl Matcher for DatasetSubCommand {
451450
}
452451
},
453452
Err(e) => {
454-
eprintln!("Error: {}", e);
453+
eprintln!("Error: {e}");
455454
return;
456455
}
457456
};
@@ -719,7 +718,7 @@ impl DatasetSubCommand {
719718
.map(String::from)
720719
.unwrap_or_default();
721720

722-
let mime = infer_mime(path).map_err(|e| format!("Failed to infer mime type. Direct upload only supports files with known mime types. Error: {}", e))?;
721+
let mime = infer_mime(path).map_err(|e| format!("Failed to infer mime type. Direct upload only supports files with known mime types. Error: {e}"))?;
723722

724723
Ok(DirectUploadBody {
725724
file_name: Some(filename),

src/cli/file.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl Matcher for FileSubCommand {
8686
evaluate_and_print_response(response);
8787
}
8888
FileSubCommand::Meta { id } => {
89-
println!("Getting file metadata for {:?}", id);
89+
println!("Getting file metadata for {id:?}");
9090
let response = runtime.block_on(metadata::get_file_meta(client, &id));
9191
evaluate_and_print_response(response);
9292
}
@@ -108,7 +108,7 @@ impl Matcher for FileSubCommand {
108108
Status::OK,
109109
),
110110
Err(e) => Response::from_message(
111-
Message::PlainMessage(format!("Error downloading file: {}", e)),
111+
Message::PlainMessage(format!("Error downloading file: {e}")),
112112
Status::ERROR,
113113
),
114114
};

src/cli/info.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,13 @@ impl Matcher for InfoSubCommand {
6464
for (key, exporter) in exporters.iter() {
6565
println!(" - {}: {}", key.bold().blue(), exporter.display_name);
6666
}
67-
println!("{}", EXPORTERS_INSTRUCTIONS.to_string());
67+
let instructions = EXPORTERS_INSTRUCTIONS.to_string();
68+
println!("{instructions}");
6869
} else {
6970
eprintln!("Error: {}", response.message.unwrap());
7071
}
7172
}
72-
Err(e) => eprintln!("Error: {:?}", e),
73+
Err(e) => eprintln!("Error: {e:?}"),
7374
}
7475
}
7576
};

src/data_access/datafile.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ async fn get_full_dv_path(client: &BaseClient, id: &Identifier) -> Result<String
264264
let directory_label = metadata.directory_label;
265265

266266
Ok(if let Some(directory_label) = directory_label {
267-
format!("{}/{}", directory_label, label)
267+
format!("{directory_label}/{label}")
268268
} else {
269269
label
270270
})
@@ -313,7 +313,7 @@ pub(crate) fn construct_range_header(
313313
Ok(match downloaded_bytes {
314314
Some(remaining_bytes) => HeaderMap::from_iter([(
315315
RANGE,
316-
HeaderValue::from_str(format!("bytes={}-", remaining_bytes).as_str())
316+
HeaderValue::from_str(format!("bytes={remaining_bytes}-").as_str())
317317
.map_err(|e| e.to_string())?,
318318
)])
319319
.into(),

src/data_access/dataset.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ pub async fn download_dataset_files(
7575
.await
7676
.map_err(|e| {
7777
format!(
78-
"Failed to fetch file bundle from dataset: {} ({})",
79-
e, version
78+
"Failed to fetch file bundle from dataset: {e} ({version})"
8079
)
8180
})?;
8281

@@ -134,7 +133,7 @@ async fn prepare_download(
134133
let version = determine_version(version, client.has_api_token());
135134
let bundle_size = get_dataset_size(client, id, &Some(version.clone()))
136135
.await
137-
.map_err(|e| format!("Failed to fetch dataset size: {}", e))?
136+
.map_err(|e| format!("Failed to fetch dataset size: {e}"))?
138137
.data
139138
.ok_or("Bundle size response has no data".to_string())?
140139
.storage_size

src/datasetversion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl Display for DatasetVersion {
5656
DatasetVersion::Latest => write!(f, ":latest"),
5757
DatasetVersion::Draft => write!(f, ":draft"),
5858
DatasetVersion::LatestPublished => write!(f, ":latest-published"),
59-
DatasetVersion::Version(v) => write!(f, "{}", v),
59+
DatasetVersion::Version(v) => write!(f, "{v}"),
6060
}
6161
}
6262
}

src/direct_upload/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub(crate) async fn create_database(
3131
// Create the database
3232
match Sqlite::create_database(&db_path).await {
3333
Ok(_) => println!("Create db success"),
34-
Err(error) => panic!("error: {}", error),
34+
Err(error) => panic!("error: {error}"),
3535
}
3636
}
3737

src/direct_upload/hasher.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -675,24 +675,24 @@ mod tests {
675675
"MD5" => {
676676
let expected_hash = format!("{:x}", md5::compute(content));
677677
let hash = hasher.compute().unwrap();
678-
assert_eq!(hash, expected_hash, "Hash for {} is incorrect", algorithm);
678+
assert_eq!(hash, expected_hash, "Hash for {algorithm} is incorrect");
679679
}
680680
"SHA-256" => {
681681
let expected_hash = format!("{:x}", sha2::Sha256::digest(content));
682682
let hash = hasher.compute().unwrap();
683-
assert_eq!(hash, expected_hash, "Hash for {} is incorrect", algorithm);
683+
assert_eq!(hash, expected_hash, "Hash for {algorithm} is incorrect");
684684
}
685685
"SHA-512" => {
686686
let expected_hash = format!("{:x}", sha2::Sha512::digest(content));
687687
let hash = hasher.compute().unwrap();
688-
assert_eq!(hash, expected_hash, "Hash for {} is incorrect", algorithm);
688+
assert_eq!(hash, expected_hash, "Hash for {algorithm} is incorrect");
689689
}
690690
"SHA-1" => {
691691
let expected_hash = format!("{:x}", sha1::Sha1::digest(content));
692692
let hash = hasher.compute().unwrap();
693-
assert_eq!(hash, expected_hash, "Hash for {} is incorrect", algorithm);
693+
assert_eq!(hash, expected_hash, "Hash for {algorithm} is incorrect");
694694
}
695-
_ => panic!("Unsupported algorithm: {}", algorithm),
695+
_ => panic!("Unsupported algorithm: {algorithm}"),
696696
}
697697
}
698698
}

0 commit comments

Comments
 (0)