Fix Clippy (#2522)

* Import Clippy config from Polkadot

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Auto clippy fix

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* No tabs in comments

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Prefer matches

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Dont drop references

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Trivial

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Refactor

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* fmt

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* add clippy to ci

* Clippy reborrow

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update client/pov-recovery/src/lib.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* Update client/pov-recovery/src/lib.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* Partially revert 'Prefer matches'

Using matches! instead of match does give less compiler
checks as per review from @chevdor.

Partially reverts 8c0609677f3ea040f77fffd5be6facf7c3fec95c

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update .cargo/config.toml

Co-authored-by: Chevdor <chevdor@users.noreply.github.com>

* Revert revert 💩

Should be fine to use matches! macro since it is an explicit whitelist,
not wildcard matching.

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: alvicsam <alvicsam@gmail.com>
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Chevdor <chevdor@users.noreply.github.com>
Co-authored-by: parity-processbot <>
This commit is contained in:
Oliver Tale-Yazdi
2023-05-06 08:01:03 +02:00
committed by GitHub
parent b72ae577a0
commit 299d25ba4b
92 changed files with 910 additions and 967 deletions
+7 -9
View File
@@ -85,7 +85,7 @@ impl RuntimeResolver for PathBuf {
}
fn runtime(id: &str) -> Runtime {
let id = id.replace("_", "-");
let id = id.replace('_', "-");
let (_, id, para_id) = extract_parachain_id(&id);
if id.starts_with("shell") {
@@ -240,7 +240,7 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
Runtime::ContractsRococo =>
Box::new(chain_spec::contracts::ContractsRococoChainSpec::from_json_file(path)?),
Runtime::BridgeHub(bridge_hub_runtime_type) =>
bridge_hub_runtime_type.chain_spec_from_json_file(path.into())?,
bridge_hub_runtime_type.chain_spec_from_json_file(path)?,
Runtime::Penpal(_para_id) =>
Box::new(chain_spec::penpal::PenpalChainSpec::from_json_file(path)?),
Runtime::Default => Box::new(
@@ -258,12 +258,10 @@ fn extract_parachain_id(id: &str) -> (&str, &str, Option<ParaId>) {
const KUSAMA_TEST_PARA_PREFIX: &str = "penpal-kusama-";
const POLKADOT_TEST_PARA_PREFIX: &str = "penpal-polkadot-";
let (norm_id, orig_id, para) = if id.starts_with(KUSAMA_TEST_PARA_PREFIX) {
let suffix = &id[KUSAMA_TEST_PARA_PREFIX.len()..];
let (norm_id, orig_id, para) = if let Some(suffix) = id.strip_prefix(KUSAMA_TEST_PARA_PREFIX) {
let para_id: u32 = suffix.parse().expect("Invalid parachain-id suffix");
(&id[..KUSAMA_TEST_PARA_PREFIX.len() - 1], id, Some(para_id))
} else if id.starts_with(POLKADOT_TEST_PARA_PREFIX) {
let suffix = &id[POLKADOT_TEST_PARA_PREFIX.len()..];
} else if let Some(suffix) = id.strip_prefix(POLKADOT_TEST_PARA_PREFIX) {
let para_id: u32 = suffix.parse().expect("Invalid parachain-id suffix");
(&id[..POLKADOT_TEST_PARA_PREFIX.len() - 1], id, Some(para_id))
} else {
@@ -813,13 +811,13 @@ pub fn run() -> Result<()> {
runner.run_node_until_exit(|config| async move {
let hwbench = (!cli.no_hardware_benchmarks).then_some(
config.database.path().map(|database_path| {
let _ = std::fs::create_dir_all(&database_path);
let _ = std::fs::create_dir_all(database_path);
sc_sysinfo::gather_hwbench(Some(database_path))
})).flatten();
let para_id = chain_spec::Extensions::try_get(&*config.chain_spec)
.map(|e| e.para_id)
.ok_or_else(|| "Could not find parachain extension in chain-spec.")?;
.ok_or("Could not find parachain extension in chain-spec.")?;
let polkadot_cli = RelayChainCli::new(
&config,
@@ -848,7 +846,7 @@ pub fn run() -> Result<()> {
info!("Parachain genesis state: {}", genesis_state);
info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });
if !collator_options.relay_chain_rpc_urls.is_empty() && cli.relaychain_args.len() > 0 {
if !collator_options.relay_chain_rpc_urls.is_empty() && !cli.relaychain_args.is_empty() {
warn!("Detected relay chain node arguments together with --relay-chain-rpc-url. This command starts a minimal Polkadot node that only uses a network-related subset of all relay chain CLI options.");
}