Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines authored and mergify[bot] committed Oct 23, 2021
1 parent 293a0d8 commit 350bb56
Show file tree
Hide file tree
Showing 18 changed files with 35 additions and 52 deletions.
1 change: 1 addition & 0 deletions account-decoder/src/parse_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ pub fn parse_token(

#[derive(Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase", tag = "type", content = "info")]
#[allow(clippy::large_enum_variant)]
pub enum TokenAccountType {
Account(UiTokenAccount),
Mint(UiMint),
Expand Down
2 changes: 1 addition & 1 deletion clap-utils/src/input_parsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ mod tests {
use std::env;
let out_dir = env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string());

format!("{}/tmp/{}-{}", out_dir, name, pubkey.to_string())
format!("{}/tmp/{}-{}", out_dir, name, pubkey)
}

#[test]
Expand Down
18 changes: 5 additions & 13 deletions cli-output/src/cli_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,10 @@ impl fmt::Display for CliEpochInfo {
"Epoch Completed Time:",
&format!(
"{}{}/{} ({} remaining)",
humantime::format_duration(time_elapsed).to_string(),
humantime::format_duration(time_elapsed),
if annotation.is_some() { "*" } else { "" },
humantime::format_duration(time_elapsed + time_remaining).to_string(),
humantime::format_duration(time_remaining).to_string(),
humantime::format_duration(time_elapsed + time_remaining),
humantime::format_duration(time_remaining),
),
)?;
if let Some(annotation) = annotation {
Expand Down Expand Up @@ -2593,11 +2593,7 @@ mod tests {
CliSignOnlyData {
blockhash: blockhash.to_string(),
message: None,
signers: vec![format!(
"{}={}",
present.pubkey().to_string(),
tx.signatures[1]
)],
signers: vec![format!("{}={}", present.pubkey(), tx.signatures[1])],
absent: vec![absent.pubkey().to_string()],
bad_sig: vec![bad.pubkey().to_string()],
}
Expand Down Expand Up @@ -2627,11 +2623,7 @@ mod tests {
CliSignOnlyData {
blockhash: blockhash.to_string(),
message: Some(expected_msg),
signers: vec![format!(
"{}={}",
present.pubkey().to_string(),
tx.signatures[1]
)],
signers: vec![format!("{}={}", present.pubkey(), tx.signatures[1])],
absent: vec![absent.pubkey().to_string()],
bad_sig: vec![bad.pubkey().to_string()],
}
Expand Down
11 changes: 4 additions & 7 deletions cli-output/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,20 +338,17 @@ pub fn write_transaction<W: io::Write>(
let sign = if reward.lamports < 0 { "-" } else { "" };
writeln!(
w,
"{} {:<44} {:^15} {:<15} {}",
"{} {:<44} {:^15} {}◎{:<14.9} ◎{:<18.9}",
prefix,
reward.pubkey,
if let Some(reward_type) = reward.reward_type {
format!("{}", reward_type)
} else {
"-".to_string()
},
format!(
"{}◎{:<14.9}",
sign,
lamports_to_sol(reward.lamports.abs() as u64)
),
format!("◎{:<18.9}", lamports_to_sol(reward.post_balance),)
sign,
lamports_to_sol(reward.lamports.abs() as u64),
lamports_to_sol(reward.post_balance)
)?;
}
}
Expand Down
1 change: 1 addition & 0 deletions core/src/cluster_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use {
},
};

#[allow(clippy::large_enum_variant)]
enum NodeId {
// TVU node obtained through gossip (staked or not).
ContactInfo(ContactInfo),
Expand Down
1 change: 1 addition & 0 deletions core/src/fetch_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ impl FetchStage {
{
inc_new_counter_debug!("fetch_stage-honor_forwards", len);
for packets in batch {
#[allow(clippy::question_mark)]
if sendr.send(packets).is_err() {
return Err(Error::Send);
}
Expand Down
5 changes: 1 addition & 4 deletions frozen-abi/macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,7 @@ fn quote_for_test(

#[cfg(RUSTC_WITH_SPECIALIZATION)]
fn test_mod_name(type_name: &Ident) -> Ident {
Ident::new(
&format!("{}_frozen_abi", type_name.to_string()),
Span::call_site(),
)
Ident::new(&format!("{}_frozen_abi", type_name), Span::call_site())
}

#[cfg(RUSTC_WITH_SPECIALIZATION)]
Expand Down
11 changes: 4 additions & 7 deletions ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,16 @@ fn output_slot_rewards(blockstore: &Blockstore, slot: Slot, method: &LedgerOutpu
for reward in rewards {
let sign = if reward.lamports < 0 { "-" } else { "" };
println!(
" {:<44} {:^15} {:<15} {} {}",
" {:<44} {:^15} {}◎{:<14.9} ◎{:<18.9} {}",
reward.pubkey,
if let Some(reward_type) = reward.reward_type {
format!("{}", reward_type)
} else {
"-".to_string()
},
format!(
"{}◎{:<14.9}",
sign,
lamports_to_sol(reward.lamports.abs() as u64)
),
format!("◎{:<18.9}", lamports_to_sol(reward.post_balance)),
sign,
lamports_to_sol(reward.lamports.abs() as u64),
lamports_to_sol(reward.post_balance),
reward
.commission
.map(|commission| format!("{:>9}%", commission))
Expand Down
1 change: 1 addition & 0 deletions ledger/src/blockstore_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,7 @@ fn process_single_slot(
Ok(())
}

#[allow(clippy::large_enum_variant)]
pub enum TransactionStatusMessage {
Batch(TransactionStatusBatch),
Freeze(Slot),
Expand Down
8 changes: 3 additions & 5 deletions log-analyzer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ impl LogLine {
format!(
"Lost {}%, {}, ({} - {}), sender {}, receiver {}",
((v1 - v2) * 100 / v1),
Byte::from_bytes(v1 - v2)
.get_appropriate_unit(true)
.to_string(),
Byte::from_bytes(v1).get_appropriate_unit(true).to_string(),
Byte::from_bytes(v2).get_appropriate_unit(true).to_string(),
Byte::from_bytes(v1 - v2).get_appropriate_unit(true),
Byte::from_bytes(v1).get_appropriate_unit(true),
Byte::from_bytes(v2).get_appropriate_unit(true),
a,
b
)
Expand Down
3 changes: 2 additions & 1 deletion programs/bpf_loader/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ fn main() {
let mut out = BufWriter::new(file);
let sysc_re = Regex::new(r#"register_syscall_by_name\([[:space:]]*b"([^"]+)","#).unwrap();
for caps in sysc_re.captures_iter(text) {
writeln!(out, "{}", caps[1].to_string()).unwrap();
let name = caps[1].to_string();
writeln!(out, "{}", name).unwrap();
}
}
6 changes: 3 additions & 3 deletions rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1999,6 +1999,7 @@ fn verify_transaction(
transaction: &SanitizedTransaction,
feature_set: &Arc<feature_set::FeatureSet>,
) -> Result<()> {
#[allow(clippy::question_mark)]
if transaction.verify().is_err() {
return Err(RpcCustomError::TransactionSignatureVerificationFailure.into());
}
Expand Down Expand Up @@ -4912,11 +4913,11 @@ pub mod tests {
r#"{"jsonrpc":"2.0","id":1,"method":"getLeaderSchedule"}"#,
&format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"getLeaderSchedule", "params": [null, {{ "identity": "{}" }}]}}"#,
bank.collector_id().to_string()
bank.collector_id()
),
&format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"getLeaderSchedule", "params": [{{ "identity": "{}" }}]}}"#,
bank.collector_id().to_string()
bank.collector_id()
),
]
.iter()
Expand Down Expand Up @@ -5657,7 +5658,6 @@ pub mod tests {
"sigVerify": true,
"replaceRecentBlockhash": true,
})
.to_string()
);
let res = io.handle_request_sync(&req, meta.clone());
let expected = json!({
Expand Down
4 changes: 2 additions & 2 deletions rpc/src/rpc_pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ mod tests {
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"signatureSubscribe","params":["{}"]}}"#,
tx.signatures[0].to_string()
tx.signatures[0]
);
let _res = io.handle_request_sync(&req);

Expand Down Expand Up @@ -971,7 +971,7 @@ mod tests {

let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"accountSubscribe","params":["{}"]}}"#,
bob_pubkey.to_string()
bob_pubkey
);
let _res = io.handle_request_sync(&req);

Expand Down
1 change: 1 addition & 0 deletions tokens/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub struct TransactionLogArgs {
pub output_path: String,
}

#[allow(clippy::large_enum_variant)]
pub enum Command {
DistributeTokens(DistributeTokensArgs),
Balances(BalancesArgs),
Expand Down
2 changes: 1 addition & 1 deletion tokens/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ mod tests {
use std::env;
let out_dir = env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string());

format!("{}/tmp/{}-{}", out_dir, name, pubkey.to_string())
format!("{}/tmp/{}-{}", out_dir, name, pubkey)
}

fn initialize_check_payer_balances_inputs(
Expand Down
6 changes: 1 addition & 5 deletions tokens/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,7 @@ pub fn update_finalized_transaction(

if let Some(e) = &transaction_status.err {
// The transaction was finalized, but execution failed. Drop it.
eprintln!(
"Error in transaction with signature {}: {}",
signature,
e.to_string()
);
eprintln!("Error in transaction with signature {}: {}", signature, e);
eprintln!("Discarding transaction record");
db.rem(&signature.to_string())?;
return Ok(None);
Expand Down
4 changes: 2 additions & 2 deletions validator/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ fn check_vote_account(
) -> Result<(), String> {
let vote_account = rpc_client
.get_account_with_commitment(vote_account_address, CommitmentConfig::confirmed())
.map_err(|err| format!("failed to fetch vote account: {}", err.to_string()))?
.map_err(|err| format!("failed to fetch vote account: {}", err))?
.value
.ok_or_else(|| format!("vote account does not exist: {}", vote_account_address))?;

Expand All @@ -331,7 +331,7 @@ fn check_vote_account(

let identity_account = rpc_client
.get_account_with_commitment(identity_pubkey, CommitmentConfig::confirmed())
.map_err(|err| format!("failed to fetch identity account: {}", err.to_string()))?
.map_err(|err| format!("failed to fetch identity account: {}", err))?
.value
.ok_or_else(|| format!("identity account does not exist: {}", identity_pubkey))?;

Expand Down
2 changes: 1 addition & 1 deletion validator/src/dashboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl Dashboard {
println_name_value("TPU Address:", &tpu.to_string());
}
if let Some(rpc) = contact_info.rpc {
println_name_value("JSON RPC URL:", &format!("http://{}", rpc.to_string()));
println_name_value("JSON RPC URL:", &format!("http://{}", rpc));
}
}

Expand Down

0 comments on commit 350bb56

Please sign in to comment.