Skip to content

Commit 7115e56

Browse files
committed
fix: autofix new clippy lint from rust 1.87.0
by running `cargo clippy --all-features --all-targets --fix` two fixes mainly were autofixable with this release: * https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args * https://rust-lang.github.io/rust-clippy/master/index.html#io_other_error
1 parent d16fd29 commit 7115e56

File tree

73 files changed

+149
-220
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+149
-220
lines changed

examples/client-cardano-database-v2/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ async fn main() -> MithrilResult<()> {
131131
)
132132
.await
133133
{
134-
println!("Could not send usage statistics to the aggregator: {:?}", e);
134+
println!("Could not send usage statistics to the aggregator: {e:?}");
135135
}
136136

137137
println!(

examples/client-cardano-database/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async fn main() -> MithrilResult<()> {
8989
.await?;
9090

9191
if let Err(e) = client.cardano_database().add_statistics(&snapshot).await {
92-
println!("Could not increment snapshot download statistics: {:?}", e);
92+
println!("Could not increment snapshot download statistics: {e:?}");
9393
}
9494

9595
println!("Computing snapshot '{}' message ...", snapshot.digest);
@@ -234,7 +234,7 @@ impl FeedbackReceiver for IndicatifFeedbackReceiver {
234234
}
235235
*certificate_validation_pb = None;
236236
}
237-
_ => panic!("Unexpected event: {:?}", event),
237+
_ => panic!("Unexpected event: {event:?}"),
238238
}
239239
}
240240
}

internal/mithril-build-script/src/fake_aggregator.rs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -286,17 +286,14 @@ pub fn extract_cardano_stake_distribution_epochs(
286286
.map(|content| {
287287
let json_value: serde_json::Value =
288288
serde_json::from_str(content).unwrap_or_else(|err| {
289-
panic!(
290-
"Failed to parse JSON in csd content: {}\nError: {}",
291-
content, err
292-
);
289+
panic!("Failed to parse JSON in csd content: {content}\nError: {err}");
293290
});
294291

295292
json_value
296293
.get("epoch")
297294
.and_then(|epoch| epoch.as_u64().map(|s| s.to_string()))
298295
.unwrap_or_else(|| {
299-
panic!("Epoch not found or invalid in csd content: {}", content);
296+
panic!("Epoch not found or invalid in csd content: {content}");
300297
})
301298
})
302299
.collect()
@@ -327,33 +324,30 @@ pub fn generate_artifact_getter(
327324
artifacts_list,
328325
r###"
329326
(
330-
"{}",
331-
r#"{}"#
332-
),"###,
333-
artifact_id, file_content
327+
"{artifact_id}",
328+
r#"{file_content}"#
329+
),"###
334330
)
335331
.unwrap();
336332
}
337333

338334
format!(
339-
r###"pub(crate) fn {}() -> BTreeMap<String, String> {{
340-
[{}
335+
r###"pub(crate) fn {fun_name}() -> BTreeMap<String, String> {{
336+
[{artifacts_list}
341337
]
342338
.into_iter()
343339
.map(|(k, v)| (k.to_owned(), v.to_owned()))
344340
.collect()
345-
}}"###,
346-
fun_name, artifacts_list
341+
}}"###
347342
)
348343
}
349344

350345
/// pub(crate) fn $fun_name() -> &'static str
351346
pub fn generate_list_getter(fun_name: &str, source_json: FileContent) -> String {
352347
format!(
353-
r###"pub(crate) fn {}() -> &'static str {{
354-
r#"{}"#
355-
}}"###,
356-
fun_name, source_json
348+
r###"pub(crate) fn {fun_name}() -> &'static str {{
349+
r#"{source_json}"#
350+
}}"###
357351
)
358352
}
359353

@@ -365,8 +359,7 @@ pub fn generate_ids_array(array_name: &str, ids: BTreeSet<ArtifactId>) -> String
365359
write!(
366360
ids_list,
367361
r#"
368-
"{}","#,
369-
id
362+
"{id}","#
370363
)
371364
.unwrap();
372365
}

internal/mithril-build-script/src/open_api.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,10 @@ pub fn generate_open_api_versions_mapping(open_api_spec_files: &[PathBuf]) -> St
6060
/// Build Open API versions mapping
6161
pub fn get_open_api_versions_mapping() -> HashMap<OpenAPIFileName, semver::Version> {{
6262
HashMap::from([
63-
{}
63+
{open_api_versions_hashmap}
6464
])
6565
}}
66-
"#,
67-
open_api_versions_hashmap
66+
"#
6867
)
6968
}
7069

internal/mithril-cli-helper/src/source_config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ mod tests {
142142
map,
143143
&"namespace".to_string(),
144144
fake.string_value,
145-
|v: String| { format!("mapped_value from {}", v) }
145+
|v: String| { format!("mapped_value from {v}") }
146146
);
147147

148148
let expected = HashMap::from([(
@@ -200,7 +200,7 @@ mod tests {
200200
map,
201201
&"namespace".to_string(),
202202
fake.option_with_value,
203-
|v: String| format!("mapped_value from {}", v)
203+
|v: String| format!("mapped_value from {v}")
204204
);
205205
register_config_value_option!(map, &"namespace".to_string(), fake.option_none);
206206

internal/mithril-doc/src/extract_clap_info.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use super::{FieldDoc, StructDoc};
55
/// Extract information of an command line argument.
66
fn extract_arg(arg: &Arg) -> FieldDoc {
77
let parameter = arg.get_id().to_string();
8-
let short_option = arg.get_short().map_or("".into(), |c| format!("-{}", c));
9-
let long_option = arg.get_long().map_or("".into(), |c| format!("--{}", c));
8+
let short_option = arg.get_short().map_or("".into(), |c| format!("-{c}"));
9+
let long_option = arg.get_long().map_or("".into(), |c| format!("--{c}"));
1010
let env_variable = arg.get_env().map(|s| format!("{}", s.to_string_lossy()));
1111
let description = arg.get_help().map_or("-".into(), StyledStr::to_string);
1212
let default_value = if arg.get_default_values().iter().count() == 0 {

internal/mithril-doc/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,19 +158,19 @@ pub struct GenerateDocCommands {
158158
impl GenerateDocCommands {
159159
fn save_doc(&self, cmd_name: &str, doc: &str) -> Result<(), String> {
160160
let output = if self.output.as_str() == DEFAULT_OUTPUT_FILE_TEMPLATE {
161-
format!("{}-command-line.md", cmd_name)
161+
format!("{cmd_name}-command-line.md")
162162
} else {
163163
self.output.clone()
164164
};
165165

166166
match File::create(&output) {
167167
Ok(mut buffer) => {
168-
if write!(buffer, "\n{}", doc).is_err() {
169-
return Err(format!("Error writing in {}", output));
168+
if write!(buffer, "\n{doc}").is_err() {
169+
return Err(format!("Error writing in {output}"));
170170
}
171171
println!("Documentation generated in file `{}`", &output);
172172
}
173-
_ => return Err(format!("Could not create {}", output)),
173+
_ => return Err(format!("Could not create {output}")),
174174
};
175175
Ok(())
176176
}
@@ -190,7 +190,7 @@ impl GenerateDocCommands {
190190
let cmd_name = cmd_to_document.get_name();
191191

192192
println!("Please note: the documentation generated is not able to indicate the environment variables used by the commands.");
193-
self.save_doc(cmd_name, format!("\n{}", doc).as_str())
193+
self.save_doc(cmd_name, format!("\n{doc}").as_str())
194194
}
195195
}
196196

internal/mithril-doc/src/markdown_formatter.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub fn doc_markdown_with_config(cmd: &mut Command, configs: HashMap<String, Stru
8787

8888
let parameters_table = doc_config_to_markdown(&command_parameters);
8989

90-
format!("{}\n{}", parameters_explanation, parameters_table)
90+
format!("{parameters_explanation}\n{parameters_table}")
9191
} else {
9292
"".to_string()
9393
}
@@ -145,7 +145,7 @@ pub fn doc_markdown_with_config(cmd: &mut Command, configs: HashMap<String, Stru
145145
level: usize,
146146
parameters_explanation: &str,
147147
) -> String {
148-
let parent_path = parent.map(|s| format!("{} ", s)).unwrap_or_default();
148+
let parent_path = parent.map(|s| format!("{s} ")).unwrap_or_default();
149149
let command_path = format!("{}{}", parent_path, cmd.get_name());
150150

151151
let title = format!("{} {}\n", "#".repeat(level), command_path);
@@ -204,11 +204,11 @@ pub fn doc_config_to_markdown(struct_doc: &StructDoc) -> String {
204204
},
205205
config
206206
.environment_variable
207-
.map_or_else(|| "-".to_string(), |x| format!("`{}`", x)),
207+
.map_or_else(|| "-".to_string(), |x| format!("`{x}`")),
208208
config.description.replace('\n', "<br/>"),
209209
config
210210
.default_value
211-
.map(|value| format!("`{}`", value))
211+
.map(|value| format!("`{value}`"))
212212
.unwrap_or("-".to_string()),
213213
config
214214
.example
@@ -509,7 +509,7 @@ mod tests {
509509

510510
let mut command = MyCommand::command();
511511
let crate_name = format_clap_command_name_to_key(env!("CARGO_PKG_NAME"));
512-
let configs = HashMap::from([(format!("{} subcommanda", crate_name), struct_doc)]);
512+
let configs = HashMap::from([(format!("{crate_name} subcommanda"), struct_doc)]);
513513
let doc = doc_markdown_with_config(&mut command, configs);
514514

515515
assert!(doc.contains("| `ConfigA` |"), "Generated doc: {doc}");

internal/mithril-metric/src/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl IntoResponse for MetricsServerError {
3131
fn into_response(self) -> Response<Body> {
3232
match self {
3333
Self::Internal(e) => {
34-
(StatusCode::INTERNAL_SERVER_ERROR, format!("Error: {:?}", e)).into_response()
34+
(StatusCode::INTERNAL_SERVER_ERROR, format!("Error: {e:?}")).into_response()
3535
}
3636
}
3737
}

internal/mithril-persistence/src/database/query/cardano_transaction/get_cardano_transaction.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ mod tests {
125125
slot_number: SlotNumber,
126126
) -> CardanoTransactionRecord {
127127
CardanoTransactionRecord::new(
128-
format!("tx-hash-{}", slot_number),
128+
format!("tx-hash-{slot_number}"),
129129
block_number,
130130
slot_number,
131-
format!("block-hash-{}", block_number),
131+
format!("block-hash-{block_number}"),
132132
)
133133
}
134134

0 commit comments

Comments
 (0)