Lint for sum and product in consensus code (#2226)
## Issue Addressed Closes #1621 ## Proposed Changes Use the `disallowed_method` lint to ban uses of `Iterator::{sum,product}` from `types` and `state_processing`. ## Additional Info The lint is turned off in the tree hash caching code, as it is performance sensitive and overflowy arithmetic is already allowed there.
This commit is contained in:
parent
0b2ccecbcf
commit
baef1db40f
5
consensus/state_processing/clippy.toml
Normal file
5
consensus/state_processing/clippy.toml
Normal file
@ -0,0 +1,5 @@
|
||||
# Disallow sum and product methods which are prone to overflow.
|
||||
disallowed-methods = [
|
||||
"core::iter::traits::iterator::Iterator::sum",
|
||||
"core::iter::traits::iterator::Iterator::product",
|
||||
]
|
@ -1,4 +1,5 @@
|
||||
#![deny(clippy::integer_arithmetic)]
|
||||
#![deny(clippy::disallowed_method)]
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
|
5
consensus/types/clippy.toml
Normal file
5
consensus/types/clippy.toml
Normal file
@ -0,0 +1,5 @@
|
||||
# Disallow sum and product methods which are prone to overflow.
|
||||
disallowed-methods = [
|
||||
"core::iter::traits::iterator::Iterator::sum",
|
||||
"core::iter::traits::iterator::Iterator::product",
|
||||
]
|
@ -1,4 +1,5 @@
|
||||
#![allow(clippy::integer_arithmetic)]
|
||||
#![allow(clippy::disallowed_method)]
|
||||
|
||||
use super::Error;
|
||||
use crate::{BeaconState, EthSpec, Hash256, Slot, Unsigned, Validator};
|
||||
|
@ -4,6 +4,7 @@
|
||||
#![recursion_limit = "128"]
|
||||
// Clippy lint set up
|
||||
#![deny(clippy::integer_arithmetic)]
|
||||
#![deny(clippy::disallowed_method)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
|
Loading…
Reference in New Issue
Block a user