Fix clippy lints behind feature gates and add new CI step all features (#2569)

Many clippy lints usually enforced by `-Dcomplexity` and `-Dcorrectness`
are not caught by CI as they are gated by `features`, like
`runtime-benchmarks`, while the clippy CI job runs with only the default
features for all targets.

This PR also adds a CI step to run clippy with `--all-features` to
ensure the code quality is maintained behind feature gates from now on.

To improve local development, clippy lints are downgraded to warnings,
but they still will result in an error at CI due to the `-Dwarnings`
rustflag.

---------

Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>
This commit is contained in:
Dónal Murray
2023-12-20 16:30:10 +00:00
committed by GitHub
parent 280aa0b573
commit d68868f64a
22 changed files with 68 additions and 91 deletions
+3 -3
View File
@@ -105,7 +105,7 @@ pub mod v3 {
// Check that no agenda overflows `MaxScheduledPerBlock`.
let max_scheduled_per_block = T::MaxScheduledPerBlock::get() as usize;
for (block_number, agenda) in Agenda::<T>::iter() {
if agenda.iter().cloned().filter_map(|s| s).count() > max_scheduled_per_block {
if agenda.iter().cloned().flatten().count() > max_scheduled_per_block {
log::error!(
target: TARGET,
"Would truncate agenda of block {:?} from {} items to {} items.",
@@ -119,7 +119,7 @@ pub mod v3 {
// Check that bounding the calls will not overflow `MAX_LENGTH`.
let max_length = T::Preimages::MAX_LENGTH as usize;
for (block_number, agenda) in Agenda::<T>::iter() {
for schedule in agenda.iter().cloned().filter_map(|s| s) {
for schedule in agenda.iter().cloned().flatten() {
match schedule.call {
frame_support::traits::schedule::MaybeHashed::Value(call) => {
let l = call.using_encoded(|c| c.len());
@@ -362,7 +362,7 @@ mod test {
Some(ScheduledV3Of::<Test> {
maybe_id: Some(vec![i as u8; 320]),
priority: 123,
call: MaybeHashed::Hash(undecodable_hash.clone()),
call: MaybeHashed::Hash(undecodable_hash),
maybe_periodic: Some((4u64, 20)),
origin: root(),
_phantom: PhantomData::<u64>::default(),