mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
Enable clippy's or_fun_call linter (#7222)
Co-authored-by: Alexey Shekhirin <a.shekhirin@gmail.com>
This commit is contained in:
@ -93,6 +93,7 @@ clippy.redundant_clone = "deny"
|
||||
clippy.trait_duplication_in_bounds = "deny"
|
||||
clippy.uninlined_format_args = "deny"
|
||||
clippy.equatable_if_let = "deny"
|
||||
clippy.or_fun_call = "deny"
|
||||
|
||||
[workspace.package]
|
||||
version = "0.2.0-beta.3"
|
||||
|
||||
@ -79,7 +79,7 @@ impl ImportCommand {
|
||||
|
||||
// add network name to data dir
|
||||
let data_dir = self.datadir.unwrap_or_chain_default(self.chain.chain);
|
||||
let config_path = self.config.clone().unwrap_or(data_dir.config_path());
|
||||
let config_path = self.config.clone().unwrap_or_else(|| data_dir.config_path());
|
||||
|
||||
let config: Config = self.load_config(config_path.clone())?;
|
||||
info!(target: "reth::cli", path = ?config_path, "Configuration loaded");
|
||||
|
||||
@ -286,14 +286,14 @@ mod tests {
|
||||
NodeCommand::try_parse_args_from(["reth", "--config", "my/path/to/reth.toml"]).unwrap();
|
||||
// always store reth.toml in the data dir, not the chain specific data dir
|
||||
let data_dir = cmd.datadir.unwrap_or_chain_default(cmd.chain.chain);
|
||||
let config_path = cmd.config.unwrap_or(data_dir.config_path());
|
||||
let config_path = cmd.config.unwrap_or_else(|| data_dir.config_path());
|
||||
assert_eq!(config_path, Path::new("my/path/to/reth.toml"));
|
||||
|
||||
let cmd = NodeCommand::try_parse_args_from(["reth"]).unwrap();
|
||||
|
||||
// always store reth.toml in the data dir, not the chain specific data dir
|
||||
let data_dir = cmd.datadir.unwrap_or_chain_default(cmd.chain.chain);
|
||||
let config_path = cmd.config.clone().unwrap_or(data_dir.config_path());
|
||||
let config_path = cmd.config.clone().unwrap_or_else(|| data_dir.config_path());
|
||||
let end = format!("reth/{}/reth.toml", SUPPORTED_CHAINS[0]);
|
||||
assert!(config_path.ends_with(end), "{:?}", cmd.config);
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ impl Command {
|
||||
|
||||
// add network name to data dir
|
||||
let data_dir = self.datadir.unwrap_or_chain_default(self.chain.chain);
|
||||
let config_path = self.config.clone().unwrap_or(data_dir.config_path());
|
||||
let config_path = self.config.clone().unwrap_or_else(|| data_dir.config_path());
|
||||
|
||||
let mut config: Config = confy::load_path(&config_path).unwrap_or_default();
|
||||
|
||||
|
||||
@ -126,7 +126,7 @@ impl Command {
|
||||
|
||||
// add network name to data dir
|
||||
let data_dir = self.datadir.unwrap_or_chain_default(self.chain.chain);
|
||||
let config_path = self.config.clone().unwrap_or(data_dir.config_path());
|
||||
let config_path = self.config.clone().unwrap_or_else(|| data_dir.config_path());
|
||||
|
||||
let config: Config = confy::load_path(config_path).unwrap_or_default();
|
||||
info!(target: "reth::cli", "reth {} starting stage {:?}", SHORT_VERSION, self.stage);
|
||||
|
||||
@ -251,7 +251,7 @@ where
|
||||
}
|
||||
old
|
||||
};
|
||||
Some(StorageEntry { value: old.unwrap_or(U256::from(0)), ..entry })
|
||||
Some(StorageEntry { value: old.unwrap_or(U256::ZERO), ..entry })
|
||||
})
|
||||
.collect();
|
||||
old_entries.sort_by_key(|entry| entry.key);
|
||||
|
||||
@ -503,7 +503,7 @@ impl NetworkConfigBuilder {
|
||||
peers_config: peers_config.unwrap_or_default(),
|
||||
sessions_config: sessions_config.unwrap_or_default(),
|
||||
chain_spec,
|
||||
block_import: block_import.unwrap_or(Box::<ProofOfStakeBlockImport>::default()),
|
||||
block_import: block_import.unwrap_or_else(|| Box::<ProofOfStakeBlockImport>::default()),
|
||||
network_mode,
|
||||
executor: executor.unwrap_or_else(|| Box::<TokioTaskExecutor>::default()),
|
||||
status,
|
||||
|
||||
@ -470,7 +470,7 @@ where
|
||||
let sync_metrics_listener = reth_stages::MetricsListener::new(sync_metrics_rx);
|
||||
executor.spawn_critical("stages metrics listener task", sync_metrics_listener);
|
||||
|
||||
let prune_config = config.prune_config()?.or(reth_config.prune.clone());
|
||||
let prune_config = config.prune_config()?.or_else(|| reth_config.prune.clone());
|
||||
|
||||
let evm_config = types.evm_config();
|
||||
let tree_config = BlockchainTreeConfig::default();
|
||||
|
||||
@ -276,7 +276,7 @@ mod builder {
|
||||
let mut cumulative_gas_used = 0;
|
||||
let block_gas_limit: u64 = attributes
|
||||
.gas_limit
|
||||
.unwrap_or(initialized_block_env.gas_limit.try_into().unwrap_or(u64::MAX));
|
||||
.unwrap_or_else(|| initialized_block_env.gas_limit.try_into().unwrap_or(u64::MAX));
|
||||
let base_fee = initialized_block_env.basefee.to::<u64>();
|
||||
|
||||
let mut executed_txs = Vec::new();
|
||||
|
||||
@ -355,7 +355,7 @@ pub(crate) fn create_txn_env(
|
||||
block_env.get_blob_gasprice().map(U256::from),
|
||||
)?;
|
||||
|
||||
let gas_limit = gas.unwrap_or(block_env.gas_limit.min(U256::from(u64::MAX)));
|
||||
let gas_limit = gas.unwrap_or_else(|| block_env.gas_limit.min(U256::from(u64::MAX)));
|
||||
let env = TxEnv {
|
||||
gas_limit: gas_limit.try_into().map_err(|_| RpcInvalidTransactionError::GasUintOverflow)?,
|
||||
nonce: nonce
|
||||
|
||||
@ -241,7 +241,7 @@ mod tests {
|
||||
let server = spawn_server().await;
|
||||
let client = hyper::Client::new();
|
||||
|
||||
let jwt = jwt.unwrap_or("".into());
|
||||
let jwt = jwt.unwrap_or_default();
|
||||
let address = format!("http://{AUTH_ADDR}:{AUTH_PORT}");
|
||||
let bearer = format!("Bearer {jwt}");
|
||||
let body = r#"{"jsonrpc": "2.0", "method": "greet_melkor", "params": [], "id": 1}"#;
|
||||
|
||||
@ -237,7 +237,7 @@ impl StaticFileProviderRW {
|
||||
.user_header()
|
||||
.block_end()
|
||||
.map(|b| b + 1)
|
||||
.unwrap_or(self.writer.user_header().expected_block_start());
|
||||
.unwrap_or_else(|| self.writer.user_header().expected_block_start());
|
||||
|
||||
if expected_block_number != next_static_file_block {
|
||||
return Err(ProviderError::UnexpectedStaticFileBlockNumber(
|
||||
|
||||
@ -51,11 +51,10 @@ impl LogFormat {
|
||||
let target = std::env::var("RUST_LOG_TARGET")
|
||||
// `RUST_LOG_TARGET` always overrides default behaviour
|
||||
.map(|val| val != "0")
|
||||
.unwrap_or(
|
||||
.unwrap_or_else(|_|
|
||||
// If `RUST_LOG_TARGET` is not set, show target in logs only if the max enabled
|
||||
// level is higher than INFO (DEBUG, TRACE)
|
||||
filter.max_level_hint().map_or(true, |max_level| max_level > tracing::Level::INFO),
|
||||
);
|
||||
filter.max_level_hint().map_or(true, |max_level| max_level > tracing::Level::INFO));
|
||||
|
||||
match self {
|
||||
LogFormat::Json => {
|
||||
|
||||
@ -232,9 +232,9 @@ impl<'b, C> HashedPostStateStorageCursor<'b, C> {
|
||||
}
|
||||
}
|
||||
// Return either non-empty entry
|
||||
_ => {
|
||||
db_item.or(post_state_item.copied().map(|(key, value)| StorageEntry { key, value }))
|
||||
}
|
||||
_ => db_item.or_else(|| {
|
||||
post_state_item.copied().map(|(key, value)| StorageEntry { key, value })
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user