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

internal/mithril-persistence/src/database/record/block_range_root.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ mod tests {
111111

112112
assert!(
113113
format!("{res:?}").contains("Invalid block range"),
114-
"Expected 'Invalid block range' error, got {:?}",
115-
res
114+
"Expected 'Invalid block range' error, got {res:?}"
116115
);
117116
}
118117
}

internal/mithril-persistence/src/database/repository/cardano_transaction_repository.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ mod tests {
12531253
tx_hash,
12541254
block_number,
12551255
slot_number,
1256-
format!("block-hash-{}", block_number),
1256+
format!("block-hash-{block_number}"),
12571257
)
12581258
}
12591259

internal/mithril-persistence/src/sqlite/cleaner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ mod tests {
115115
connection
116116
.execute(format!(
117117
"INSERT INTO test (id, text) VALUES {}",
118-
ids.map(|i| format!("({}, 'some text to fill the db')", i))
118+
ids.map(|i| format!("({i}, 'some text to fill the db')"))
119119
.collect::<Vec<String>>()
120120
.join(", ")
121121
))

internal/mithril-persistence/src/sqlite/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ mod test {
5656

5757
assert!(
5858
requirement.matches(&version),
59-
"Sqlite version {} is lower than 3.42.0",
60-
version
59+
"Sqlite version {version} is lower than 3.42.0"
6160
)
6261
}
6362
}

mithril-aggregator/benches/cardano_transactions_get.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ fn generate_transactions(nb_transactions: usize) -> Vec<CardanoTransaction> {
3232
(0..nb_transactions)
3333
.map(|i| {
3434
CardanoTransaction::new(
35-
format!("tx_hash-{}", i),
35+
format!("tx_hash-{i}"),
3636
BlockNumber(i as u64),
3737
SlotNumber(i as u64 * 100),
38-
format!("block_hash-{}", i),
38+
format!("block_hash-{i}"),
3939
)
4040
})
4141
.collect()

mithril-aggregator/benches/cardano_transactions_import.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ fn generate_transactions(nb_transactions: usize) -> Vec<CardanoTransaction> {
2727
(0..nb_transactions)
2828
.map(|i| {
2929
CardanoTransaction::new(
30-
format!("tx_hash-{}", i),
30+
format!("tx_hash-{i}"),
3131
BlockNumber(i as u64),
3232
SlotNumber(i as u64 + 1),
33-
format!("block_hash-{}", i),
33+
format!("block_hash-{i}"),
3434
)
3535
})
3636
.collect()

mithril-aggregator/src/artifact_builder/cardano_database_artifacts/digest.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -690,15 +690,13 @@ mod tests {
690690
let remaining_files = path_content(&digests_dir);
691691
assert!(
692692
remaining_files.is_empty(),
693-
"There should be no remaining files in digests folder, but found: {:?}",
694-
remaining_files
693+
"There should be no remaining files in digests folder, but found: {remaining_files:?}"
695694
);
696695

697696
let remaining_files = path_content(&digests_archive_dir);
698697
assert!(
699698
remaining_files.is_empty(),
700-
"There should be no remaining files in archive folder, but found: {:?}",
701-
remaining_files
699+
"There should be no remaining files in archive folder, but found: {remaining_files:?}"
702700
);
703701
}
704702
}

mithril-aggregator/src/dependency_injection/builder/enablers/cardano_node.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ mod tests {
202202
let is_activated = cardano_transactions_preloader.is_activated().await.unwrap();
203203
assert_eq!(
204204
expected_activation, is_activated,
205-
"'is_activated' expected {}, but was {}",
206-
expected_activation, is_activated
205+
"'is_activated' expected {expected_activation}, but was {is_activated}"
207206
);
208207
}
209208
}

mithril-aggregator/src/http_server/routes/signer_routes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ mod tests {
535535

536536
let response = request()
537537
.method(method)
538-
.path(&format!("{base_path}/{}", asked_epoch))
538+
.path(&format!("{base_path}/{asked_epoch}"))
539539
.reply(&setup_router(RouterState::new_with_dummy_config(Arc::new(
540540
dependency_manager,
541541
))))

mithril-aggregator/src/http_server/validators/prover_transactions_hash_validator.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ mod tests {
104104
"invalid_transaction_hashes",
105105
"Transaction hash must contain only hexadecimal characters"
106106
),
107-
"Invalid hash: {}",
108-
hash
107+
"Invalid hash: {hash}"
109108
);
110109
}
111110
}

mithril-aggregator/src/runtime/runner.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,7 @@ impl AggregatorRunnerTrait for AggregatorRunner {
402402
.read_era_epoch_token(epoch)
403403
.await
404404
.with_context(|| {
405-
format!(
406-
"EraReader can not get era epoch token for current epoch: '{}'",
407-
epoch
408-
)
405+
format!("EraReader can not get era epoch token for current epoch: '{epoch}'")
409406
})?;
410407

411408
let current_era = token

mithril-aggregator/src/services/aggregator_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ impl AggregatorClientError {
119119
} else if json_value.is_null() {
120120
canonical_reason.to_string()
121121
} else {
122-
format!("{}: {}", canonical_reason, json_value)
122+
format!("{canonical_reason}: {json_value}")
123123
}
124124
} else {
125125
let response_text = response.text().await.unwrap_or_default();
126-
format!("{}: {}", canonical_reason, response_text)
126+
format!("{canonical_reason}: {response_text}")
127127
}
128128
}
129129
}

mithril-aggregator/src/services/cardano_transactions_importer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ mod tests {
266266
(*start_block_number..*(start_block_number + number_of_consecutive_block))
267267
.map(|block_number| {
268268
ScannedBlock::new(
269-
format!("block_hash-{}", block_number),
269+
format!("block_hash-{block_number}"),
270270
BlockNumber(block_number),
271271
SlotNumber(block_number * 100),
272272
vec![format!("tx_hash-{}", block_number)],

0 commit comments

Comments
 (0)