Apply some clippy lints (#11154)

* Apply some clippy hints

* Revert clippy ci changes

* Update client/cli/src/commands/generate.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/cli/src/commands/inspect_key.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/db/src/bench.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/db/src/bench.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/service/src/client/block_rules.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/service/src/client/block_rules.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/network/src/transactions.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/network/src/protocol.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Revert due to missing `or_default` function.

* Fix compilation and simplify code

* Undo change that corrupts benchmark.

* fix clippy

* Update client/service/test/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/state-db/src/noncanonical.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/state-db/src/noncanonical.rs

remove leftovers!

* Update client/tracing/src/logging/directives.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update utils/fork-tree/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* added needed ref

* Update frame/referenda/src/benchmarking.rs

* Simplify byte-vec creation

* let's just not overlap the ranges

* Correction

* cargo fmt

* Update utils/frame/benchmarking-cli/src/shared/stats.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update utils/frame/benchmarking-cli/src/pallet/command.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update utils/frame/benchmarking-cli/src/pallet/command.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Giles Cope <gilescope@gmail.com>
This commit is contained in:
Falco Hirschenberger
2022-04-30 23:28:27 +02:00
committed by GitHub
parent a990473cf9
commit b581604aa7
368 changed files with 1927 additions and 2236 deletions
@@ -61,16 +61,11 @@ impl GenerateCmd {
};
let mnemonic = Mnemonic::new(words, Language::English);
let password = self.keystore_params.read_password()?;
let output = self.output_scheme.output_type.clone();
let output = self.output_scheme.output_type;
with_crypto_scheme!(
self.crypto_scheme.scheme,
print_from_uri(
mnemonic.phrase(),
password,
self.network_scheme.network.clone(),
output,
)
print_from_uri(mnemonic.phrase(), password, self.network_scheme.network, output)
);
Ok(())
}
@@ -87,15 +87,15 @@ impl InspectKeyCmd {
self.crypto_scheme.scheme,
print_from_public(
&uri,
self.network_scheme.network.clone(),
self.output_scheme.output_type.clone(),
self.network_scheme.network,
self.output_scheme.output_type,
)
)?;
} else {
if let Some(ref expect_public) = self.expect_public {
with_crypto_scheme!(
self.crypto_scheme.scheme,
expect_public_from_phrase(&&expect_public, &uri, password.as_ref(),)
expect_public_from_phrase(expect_public, &uri, password.as_ref())
)?;
}
@@ -104,8 +104,8 @@ impl InspectKeyCmd {
print_from_uri(
&uri,
password,
self.network_scheme.network.clone(),
self.output_scheme.output_type.clone(),
self.network_scheme.network,
self.output_scheme.output_type,
)
);
}
@@ -60,7 +60,7 @@ impl PurgeChainCmd {
io::stdin().read_line(&mut input)?;
let input = input.trim();
match input.chars().nth(0) {
match input.chars().next() {
Some('y') | Some('Y') => {},
_ => {
println!("Aborted");
+2 -2
View File
@@ -74,7 +74,7 @@ pub fn print_from_uri<Pair>(
{
let password = password.as_ref().map(|s| s.expose_secret().as_str());
let network_id = String::from(unwrap_or_default_ss58_version(network_override));
if let Ok((pair, seed)) = Pair::from_phrase(uri, password.clone()) {
if let Ok((pair, seed)) = Pair::from_phrase(uri, password) {
let public_key = pair.public();
let network_override = unwrap_or_default_ss58_version(network_override);
@@ -113,7 +113,7 @@ pub fn print_from_uri<Pair>(
);
},
}
} else if let Ok((pair, seed)) = Pair::from_string_with_seed(uri, password.clone()) {
} else if let Ok((pair, seed)) = Pair::from_string_with_seed(uri, password) {
let public_key = pair.public();
let network_override = unwrap_or_default_ss58_version(network_override);
+10 -10
View File
@@ -64,8 +64,8 @@ impl VanityCmd {
print_from_uri(
&formated_seed,
None,
self.network_scheme.network.clone(),
self.output_scheme.output_type.clone(),
self.network_scheme.network,
self.output_scheme.output_type,
),
);
Ok(())
@@ -98,7 +98,7 @@ where
let p = Pair::from_seed(&seed);
let ss58 = p.public().into_account().to_ss58check_with_version(network_override);
let score = calculate_score(&desired, &ss58);
let score = calculate_score(desired, &ss58);
if score > best || desired.len() < 2 {
best = score;
if best >= top {
@@ -117,20 +117,20 @@ where
fn good_waypoint(done: u64) -> u64 {
match done {
0..=1_000_000 => 100_000,
0..=10_000_000 => 1_000_000,
0..=100_000_000 => 10_000_000,
_ => 100_000_000,
1_000_001..=10_000_000 => 1_000_000,
10_000_001..=100_000_000 => 10_000_000,
100_000_001.. => 100_000_000,
}
}
fn next_seed(seed: &mut [u8]) {
for i in 0..seed.len() {
match seed[i] {
for s in seed {
match s {
255 => {
seed[i] = 0;
*s = 0;
},
_ => {
seed[i] += 1;
*s += 1;
break
},
}
+2 -2
View File
@@ -40,7 +40,7 @@ use std::{net::SocketAddr, path::PathBuf};
pub(crate) const NODE_NAME_MAX_LENGTH: usize = 64;
/// Default sub directory to store network config.
pub(crate) const DEFAULT_NETWORK_CONFIG_PATH: &'static str = "network";
pub(crate) const DEFAULT_NETWORK_CONFIG_PATH: &str = "network";
/// The recommended open file descriptor limit to be configured for the process.
const RECOMMENDED_OPEN_FILE_DESCRIPTOR_LIMIT: u64 = 10_000;
@@ -629,7 +629,7 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
}
// Call hook for custom profiling setup.
logger_hook(&mut logger, &config);
logger_hook(&mut logger, config);
logger.init()?;
+2 -2
View File
@@ -122,7 +122,7 @@ pub trait SubstrateCli: Sized {
let app = <Self as CommandFactory>::command();
let mut full_version = Self::impl_version();
full_version.push_str("\n");
full_version.push('\n');
let name = Self::executable_name();
let author = Self::author();
@@ -164,7 +164,7 @@ pub trait SubstrateCli: Sized {
let app = <Self as CommandFactory>::command();
let mut full_version = Self::impl_version();
full_version.push_str("\n");
full_version.push('\n');
let name = Self::executable_name();
let author = Self::author();
@@ -26,7 +26,7 @@ use std::{
};
/// default sub directory for the key store
const DEFAULT_KEYSTORE_CONFIG_PATH: &'static str = "keystore";
const DEFAULT_KEYSTORE_CONFIG_PATH: &str = "keystore";
/// Parameters of the keystore
#[derive(Debug, Clone, Args)]
@@ -112,7 +112,7 @@ fn invalid_node_key(e: impl std::fmt::Display) -> error::Error {
/// Parse a Ed25519 secret key from a hex string into a `sc_network::Secret`.
fn parse_ed25519_secret(hex: &str) -> error::Result<sc_network::config::Ed25519Secret> {
H256::from_str(&hex).map_err(invalid_node_key).and_then(|bytes| {
H256::from_str(hex).map_err(invalid_node_key).and_then(|bytes| {
ed25519::SecretKey::from_bytes(bytes)
.map(sc_network::config::Secret::Input)
.map_err(invalid_node_key)
@@ -126,7 +126,7 @@ impl SharedParams {
/// Receiver to process tracing messages.
pub fn tracing_receiver(&self) -> sc_service::TracingReceiver {
self.tracing_receiver.clone().into()
self.tracing_receiver.into()
}
/// Comma separated list of targets for tracing.