Skip to content

Commit 8314f0e

Browse files
committed
chore: Apply Clippy lint useless_format
1 parent e4af663 commit 8314f0e

File tree

23 files changed

+73
-105
lines changed

23 files changed

+73
-105
lines changed

stackslib/src/burnchains/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1620,7 +1620,7 @@ impl BurnchainDB {
16201620
conn,
16211621
"SELECT affirmation_map FROM overrides WHERE reward_cycle = ?1",
16221622
params![u64_to_sql(reward_cycle)?],
1623-
|| format!("BUG: more than one override affirmation map for the same reward cycle"),
1623+
|| "BUG: more than one override affirmation map for the same reward cycle".to_string(),
16241624
)?;
16251625
if let Some(am) = &am_opt {
16261626
assert_eq!((am.len() + 1) as u64, reward_cycle);

stackslib/src/chainstate/burn/db/sortdb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ impl db_keys {
942942
}
943943

944944
pub fn pox_reward_set_payouts_key() -> String {
945-
format!("sortition_db::reward_set::payouts")
945+
"sortition_db::reward_set::payouts".to_string()
946946
}
947947

948948
pub fn pox_reward_set_payouts_value(addrs: Vec<PoxAddress>, payout_per_addr: u128) -> String {

stackslib/src/chainstate/stacks/auth.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,7 @@ impl StacksMessageCodec for OrderIndependentMultisigSpendingCondition {
383383

384384
// must all be compressed if we're using P2WSH
385385
if have_uncompressed && hash_mode == OrderIndependentMultisigHashMode::P2WSH {
386-
let msg = format!(
387-
"Failed to deserialize order independent multisig spending condition: expected compressed keys only"
388-
);
386+
let msg = "Failed to deserialize order independent multisig spending condition: expected compressed keys only".to_string();
389387
test_debug!("{msg}");
390388
return Err(codec_error::DeserializeError(msg));
391389
}

stackslib/src/chainstate/stacks/boot/docs.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,9 @@ pub fn make_json_boot_contracts_reference() -> String {
160160
&contract_supporting_docs,
161161
ClarityVersion::Clarity1,
162162
);
163-
format!(
164-
"{}",
165-
serde_json::to_string(&api_out).expect("Failed to serialize documentation")
166-
)
163+
serde_json::to_string(&api_out)
164+
.expect("Failed to serialize documentation")
165+
.to_string()
167166
}
168167

169168
#[cfg(test)]

stackslib/src/chainstate/stacks/boot/mod.rs

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,7 @@ impl RewardSet {
280280
/// If there are no reward set signers, a ChainstateError is returned.
281281
pub fn total_signing_weight(&self) -> Result<u32, String> {
282282
let Some(ref reward_set_signers) = self.signers else {
283-
return Err(format!(
284-
"Unable to calculate total weight - No signers in reward set"
285-
));
283+
return Err("Unable to calculate total weight - No signers in reward set".to_string());
286284
};
287285
Ok(reward_set_signers
288286
.iter()
@@ -630,17 +628,12 @@ impl StacksChainState {
630628
sortdb: &SortitionDB,
631629
stacks_block_id: &StacksBlockId,
632630
) -> Result<u128, Error> {
633-
self.eval_boot_code_read_only(
634-
sortdb,
635-
stacks_block_id,
636-
"pox",
637-
&format!("(get-stacking-minimum)"),
638-
)
639-
.map(|value| {
640-
value
641-
.expect_u128()
642-
.expect("FATAL: unexpected PoX structure")
643-
})
631+
self.eval_boot_code_read_only(sortdb, stacks_block_id, "pox", "(get-stacking-minimum)")
632+
.map(|value| {
633+
value
634+
.expect_u128()
635+
.expect("FATAL: unexpected PoX structure")
636+
})
644637
}
645638

646639
pub fn get_total_ustx_stacked(
@@ -1743,11 +1736,7 @@ pub mod test {
17431736
}
17441737

17451738
pub fn get_balance(peer: &mut TestPeer, addr: &PrincipalData) -> u128 {
1746-
let value = eval_at_tip(
1747-
peer,
1748-
"pox",
1749-
&format!("(stx-get-balance '{})", addr),
1750-
);
1739+
let value = eval_at_tip(peer, "pox", &format!("(stx-get-balance '{addr})"));
17511740
if let Value::UInt(balance) = value {
17521741
return balance;
17531742
} else {
@@ -1759,11 +1748,7 @@ pub mod test {
17591748
peer: &mut TestPeer,
17601749
addr: &PrincipalData,
17611750
) -> Option<(PoxAddress, u128, u128, Vec<u128>)> {
1762-
let value_opt = eval_at_tip(
1763-
peer,
1764-
"pox-4",
1765-
&format!("(get-stacker-info '{})", addr),
1766-
);
1751+
let value_opt = eval_at_tip(peer, "pox-4", &format!("(get-stacker-info '{addr})"));
17671752
let data = if let Some(d) = value_opt.expect_optional().unwrap() {
17681753
d
17691754
} else {
@@ -1812,11 +1797,7 @@ pub mod test {
18121797
peer: &mut TestPeer,
18131798
addr: &PrincipalData,
18141799
) -> Option<(u128, PoxAddress, u128, u128)> {
1815-
let value_opt = eval_at_tip(
1816-
peer,
1817-
"pox",
1818-
&format!("(get-stacker-info '{})", addr),
1819-
);
1800+
let value_opt = eval_at_tip(peer, "pox", &format!("(get-stacker-info '{addr})"));
18201801
let data = if let Some(d) = value_opt.expect_optional().unwrap() {
18211802
d
18221803
} else {

stackslib/src/chainstate/stacks/boot/pox_2_tests.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,14 @@ pub fn check_pox_print_event(
282282
Some(v) => {
283283
if v != &inner_val {
284284
wrong.push((
285-
format!("{}", &inner_key),
285+
(&inner_key).to_string(),
286286
format!("{}", v),
287287
format!("{}", &inner_val),
288288
));
289289
}
290290
}
291291
None => {
292-
missing.push(format!("{}", &inner_key));
292+
missing.push((&inner_key).to_string());
293293
}
294294
}
295295
// assert_eq!(inner_tuple.data_map.get(inner_key), Some(&inner_val));
@@ -1466,15 +1466,15 @@ fn delegate_stack_increase() {
14661466

14671467
assert_eq!(first_v2_cycle, EXPECTED_FIRST_V2_CYCLE);
14681468

1469-
eprintln!("First v2 cycle = {}", first_v2_cycle);
1469+
eprintln!("First v2 cycle = {first_v2_cycle}");
14701470

14711471
let epochs = StacksEpoch::all(0, 0, EMPTY_SORTITIONS as u64 + 10);
14721472

14731473
let observer = TestEventObserver::new();
14741474

14751475
let (mut peer, mut keys) = instantiate_pox_peer_with_epoch(
14761476
&burnchain,
1477-
&format!("pox_2_delegate_stack_increase"),
1477+
"pox_2_delegate_stack_increase",
14781478
Some(epochs.clone()),
14791479
Some(&observer),
14801480
);
@@ -1830,7 +1830,7 @@ fn stack_increase() {
18301830

18311831
let (mut peer, mut keys) = instantiate_pox_peer_with_epoch(
18321832
&burnchain,
1833-
&format!("test_simple_pox_2_increase"),
1833+
"test_simple_pox_2_increase",
18341834
Some(epochs.clone()),
18351835
Some(&observer),
18361836
);
@@ -4509,7 +4509,7 @@ fn stack_aggregation_increase() {
45094509

45104510
let (mut peer, mut keys) = instantiate_pox_peer_with_epoch(
45114511
&burnchain,
4512-
&format!("pox_2_stack_aggregation_increase"),
4512+
"pox_2_stack_aggregation_increase",
45134513
Some(epochs.clone()),
45144514
Some(&observer),
45154515
);
@@ -4959,7 +4959,7 @@ fn stack_in_both_pox1_and_pox2() {
49594959

49604960
let (mut peer, mut keys) = instantiate_pox_peer_with_epoch(
49614961
&burnchain,
4962-
&format!("stack_in_both_pox1_and_pox2"),
4962+
"stack_in_both_pox1_and_pox2",
49634963
Some(epochs.clone()),
49644964
Some(&observer),
49654965
);

stackslib/src/chainstate/stacks/db/blocks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ impl StacksChainState {
475475

476476
let _ = StacksChainState::mkdirs(&block_path)?;
477477

478-
block_path.push(format!("{}", to_hex(block_hash_bytes)));
478+
block_path.push(to_hex(block_hash_bytes).to_string());
479479
let blocks_path_str = block_path
480480
.to_str()
481481
.ok_or_else(|| Error::DBError(db_error::ParseError))?

stackslib/src/chainstate/stacks/db/transactions.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ impl StacksTransactionReceipt {
212212
span.start_line, span.start_column, check_error.diagnostic.message
213213
)
214214
} else {
215-
format!("{}", check_error.diagnostic.message)
215+
check_error.diagnostic.message.to_string()
216216
}
217217
}
218218
clarity_error::Parse(ref parse_error) => {
@@ -222,7 +222,7 @@ impl StacksTransactionReceipt {
222222
span.start_line, span.start_column, parse_error.diagnostic.message
223223
)
224224
} else {
225-
format!("{}", parse_error.diagnostic.message)
225+
parse_error.diagnostic.message.to_string()
226226
}
227227
}
228228
_ => error.to_string(),
@@ -980,14 +980,14 @@ impl StacksChainState {
980980
// post-conditions are not allowed for this variant, since they're non-sensical.
981981
// Their presence in this variant makes the transaction invalid.
982982
if !tx.post_conditions.is_empty() {
983-
let msg = format!("Invalid Stacks transaction: TokenTransfer transactions do not support post-conditions");
983+
let msg = "Invalid Stacks transaction: TokenTransfer transactions do not support post-conditions".to_string();
984984
info!("{}", &msg; "txid" => %tx.txid());
985985

986986
return Err(Error::InvalidStacksTransaction(msg, false));
987987
}
988988

989989
if *addr == origin_account.principal {
990-
let msg = format!("Invalid TokenTransfer: address tried to send to itself");
990+
let msg = "Invalid TokenTransfer: address tried to send to itself".to_string();
991991
info!("{}", &msg; "txid" => %tx.txid());
992992
return Err(Error::InvalidStacksTransaction(msg, false));
993993
}
@@ -1392,7 +1392,7 @@ impl StacksChainState {
13921392
// post-conditions are not allowed for this variant, since they're non-sensical.
13931393
// Their presence in this variant makes the transaction invalid.
13941394
if !tx.post_conditions.is_empty() {
1395-
let msg = format!("Invalid Stacks transaction: PoisonMicroblock transactions do not support post-conditions");
1395+
let msg = "Invalid Stacks transaction: PoisonMicroblock transactions do not support post-conditions".to_string();
13961396
info!("{}", &msg);
13971397

13981398
return Err(Error::InvalidStacksTransaction(msg, false));
@@ -1424,7 +1424,7 @@ impl StacksChainState {
14241424
// post-conditions are not allowed for this variant, since they're non-sensical.
14251425
// Their presence in this variant makes the transaction invalid.
14261426
if !tx.post_conditions.is_empty() {
1427-
let msg = format!("Invalid Stacks transaction: TenureChange transactions do not support post-conditions");
1427+
let msg = "Invalid Stacks transaction: TenureChange transactions do not support post-conditions".to_string();
14281428
info!("{msg}");
14291429

14301430
return Err(Error::InvalidStacksTransaction(msg, false));

stackslib/src/clarity_cli.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,21 +515,21 @@ impl CLIHeadersDB {
515515
"CREATE TABLE IF NOT EXISTS cli_chain_tips(id INTEGER PRIMARY KEY AUTOINCREMENT, block_hash TEXT UNIQUE NOT NULL);",
516516
NO_PARAMS
517517
),
518-
&format!("FATAL: failed to create 'cli_chain_tips' table"),
518+
"FATAL: failed to create 'cli_chain_tips' table",
519519
);
520520

521521
friendly_expect(
522522
tx.execute(
523523
"CREATE TABLE IF NOT EXISTS cli_config(testnet BOOLEAN NOT NULL);",
524524
NO_PARAMS,
525525
),
526-
&format!("FATAL: failed to create 'cli_config' table"),
526+
"FATAL: failed to create 'cli_config' table",
527527
);
528528

529529
if !mainnet {
530530
friendly_expect(
531531
tx.execute("INSERT INTO cli_config (testnet) VALUES (?1)", &[&true]),
532-
&format!("FATAL: failed to set testnet flag"),
532+
"FATAL: failed to set testnet flag",
533533
);
534534
}
535535

stackslib/src/clarity_vm/tests/contracts.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,13 +1322,12 @@ fn test_block_heights_across_versions_traits_3_from_2() {
13221322
(contract-call? get-trait get-int)
13231323
)
13241324
"#;
1325-
let contract_e3c3 = format!(
1326-
r#"
1325+
let contract_e3c3 = r#"
13271326
(define-public (get-int)
13281327
(ok (+ stacks-block-height tenure-height))
13291328
)
13301329
"#
1331-
);
1330+
.to_string();
13321331

13331332
sim.execute_next_block(|_env| {});
13341333

@@ -1465,14 +1464,13 @@ fn test_block_heights_across_versions_traits_2_from_3() {
14651464
(ok (+ stacks-block-height (var-get tenure-height)))
14661465
)
14671466
"#;
1468-
let contract_e3c3 = format!(
1469-
r#"
1467+
let contract_e3c3 = r#"
14701468
(define-trait getter ((get-int () (response uint uint))))
14711469
(define-public (get-it (get-trait <getter>))
14721470
(contract-call? get-trait get-int)
14731471
)
14741472
"#
1475-
);
1473+
.to_string();
14761474

14771475
sim.execute_next_block(|_env| {});
14781476

0 commit comments

Comments
 (0)