diff --git a/api/src/handlers/blocks_api.rs b/api/src/handlers/blocks_api.rs index aabb29fb..9c2b0b27 100644 --- a/api/src/handlers/blocks_api.rs +++ b/api/src/handlers/blocks_api.rs @@ -60,15 +60,15 @@ impl HeaderHandler { fn get_header_for_output(&self, commit_id: String) -> Result { let oid = get_output(&self.chain, &commit_id)?.1; match w(&self.chain).get_header_for_output(&oid) { - Ok(header) => return Ok(BlockHeaderPrintable::from_header(&header)), - Err(_) => return Err(ErrorKind::NotFound)?, + Ok(header) => Ok(BlockHeaderPrintable::from_header(&header)), + Err(_) => Err(ErrorKind::NotFound)?, } } } impl Handler for HeaderHandler { fn get(&self, req: Request) -> ResponseFuture { - let el = match req.uri().path().trim_right_matches("/").rsplit("/").next() { + let el = match req.uri().path().trim_right_matches('/').rsplit('/').next() { None => return response(StatusCode::BAD_REQUEST, "invalid url"), Some(el) => el, }; @@ -125,12 +125,12 @@ fn check_block_param(input: &String) -> Result<(), Error> { "Not a valid hash or height.".to_owned(), ))?; } - return Ok(()); + Ok(()) } impl Handler for BlockHandler { fn get(&self, req: Request) -> ResponseFuture { - let el = match req.uri().path().trim_right_matches("/").rsplit("/").next() { + let el = match req.uri().path().trim_right_matches('/').rsplit('/').next() { None => return response(StatusCode::BAD_REQUEST, "invalid url"), Some(el) => el, }; diff --git a/api/src/handlers/chain_api.rs b/api/src/handlers/chain_api.rs index 150de682..91083867 100644 --- a/api/src/handlers/chain_api.rs +++ b/api/src/handlers/chain_api.rs @@ -111,7 +111,7 @@ impl OutputHandler { for (k, id) in params { if k == "id" { - for id in id.split(",") { + for id in id.split(',') { commitments.push(id.to_owned()); } } @@ -178,7 +178,7 @@ impl OutputHandler { if let Some(ids) = params.get("id") { for id in ids { - for id in id.split(",") { + for id in id.split(',') { if let Ok(x) = util::from_hex(String::from(id)) { commitments.push(Commitment::from_vec(x)); } @@ -223,7 +223,7 @@ impl OutputHandler { impl Handler for OutputHandler { fn get(&self, req: Request) -> ResponseFuture { - let command = match req.uri().path().trim_right_matches("/").rsplit("/").next() { + let command = match req.uri().path().trim_right_matches('/').rsplit('/').next() { Some(c) => c, None => return response(StatusCode::BAD_REQUEST, "invalid url"), }; diff --git a/api/src/handlers/peers_api.rs b/api/src/handlers/peers_api.rs index c700b54b..2dd7be11 100644 --- a/api/src/handlers/peers_api.rs +++ b/api/src/handlers/peers_api.rs @@ -56,7 +56,7 @@ pub struct PeerHandler { impl Handler for PeerHandler { fn get(&self, req: Request) -> ResponseFuture { - let command = match req.uri().path().trim_right_matches("/").rsplit("/").next() { + let command = match req.uri().path().trim_right_matches('/').rsplit('/').next() { Some(c) => c, None => return response(StatusCode::BAD_REQUEST, "invalid url"), }; @@ -73,7 +73,7 @@ impl Handler for PeerHandler { } } fn post(&self, req: Request) -> ResponseFuture { - let mut path_elems = req.uri().path().trim_right_matches("/").rsplit("/"); + let mut path_elems = req.uri().path().trim_right_matches('/').rsplit('/'); let command = match path_elems.next() { None => return response(StatusCode::BAD_REQUEST, "invalid url"), Some(c) => c, diff --git a/core/src/consensus.rs b/core/src/consensus.rs index a6d0ef84..059ffa4f 100644 --- a/core/src/consensus.rs +++ b/core/src/consensus.rs @@ -250,7 +250,7 @@ impl HeaderInfo { /// Move value linearly toward a goal pub fn damp(actual: u64, goal: u64, damp_factor: u64) -> u64 { - (1 * actual + (damp_factor - 1) * goal) / damp_factor + (actual + (damp_factor - 1) * goal) / damp_factor } /// limit value to be within some factor from a goal diff --git a/core/src/core/block.rs b/core/src/core/block.rs index 72f62ba6..b36d0409 100644 --- a/core/src/core/block.rs +++ b/core/src/core/block.rs @@ -418,6 +418,7 @@ impl Block { /// TODO - Move this somewhere where only tests will use it. /// *** Only used in tests. *** /// + #[warn(clippy::new_ret_no_self)] pub fn new( prev: &BlockHeader, txs: Vec, diff --git a/core/src/genesis.rs b/core/src/genesis.rs index 0947a505..8dc37797 100644 --- a/core/src/genesis.rs +++ b/core/src/genesis.rs @@ -17,6 +17,8 @@ // required for genesis replacement //! #![allow(unused_imports)] +#![cfg_attr(feature = "cargo-clippy", allow(clippy::unreadable_literal))] + use chrono::prelude::{TimeZone, Utc}; use crate::core; diff --git a/keychain/src/mnemonic.rs b/keychain/src/mnemonic.rs index b6858504..1dfb66bf 100644 --- a/keychain/src/mnemonic.rs +++ b/keychain/src/mnemonic.rs @@ -89,7 +89,7 @@ pub fn to_entropy(mnemonic: &str) -> Result, Error> { for index in indexes.iter().rev() { for i in 0..11 { let bit = index & (1 << i) != 0; - entropy[datalen - loc / 8] |= (bit as u8) << loc % 8; + entropy[datalen - loc / 8] |= (bit as u8) << (loc % 8); loc += 1; } } @@ -99,7 +99,7 @@ pub fn to_entropy(mnemonic: &str) -> Result, Error> { sha2sum.input(&entropy.clone()); hash.copy_from_slice(sha2sum.result().as_slice()); - let actual = (hash[0] >> 8 - checksum_bits) & mask; + let actual = (hash[0] >> (8 - checksum_bits)) & mask; if actual != checksum { return Err(Error::BadChecksum(checksum, actual)); @@ -134,13 +134,13 @@ pub fn from_entropy(entropy: &Vec) -> Result { for byte in entropy.iter() { for i in (0..8).rev() { let bit = byte & (1 << i) != 0; - indexes[loc / 11] |= (bit as u16) << 10 - (loc % 11); + indexes[loc / 11] |= (bit as u16) << (10 - (loc % 11)); loc += 1; } } for i in (0..checksum_bits).rev() { let bit = checksum & (1 << i) != 0; - indexes[loc / 11] |= (bit as u16) << 10 - (loc % 11); + indexes[loc / 11] |= (bit as u16) << (10 - (loc % 11)); loc += 1; }