Skip to content

Commit 38dc713

Browse files
committed
fix clippy
1 parent 41bf245 commit 38dc713

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pallets/governance/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"]
1717
[dependencies]
1818
codec = { workspace = true, features = ["max-encoded-len"] }
1919
scale-info = { workspace = true, features = ["derive"] }
20+
frame.workspace = true
2021
subtensor-macros.workspace = true
2122
frame-benchmarking = { optional = true, workspace = true }
2223
frame-support.workspace = true

pallets/governance/src/lib.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
extern crate alloc;
44

5+
use frame::arithmetic::CheckedRem;
56
use frame_support::{
67
dispatch::{GetDispatchInfo, RawOrigin},
78
pallet_prelude::*,
@@ -113,6 +114,7 @@ pub trait CollectiveMembersProvider<T: Config> {
113114
}
114115

115116
#[frame_support::pallet]
117+
#[allow(clippy::expect_used)]
116118
pub mod pallet {
117119
use super::*;
118120

@@ -401,8 +403,14 @@ pub mod pallet {
401403
let economic_collective = EconomicCollective::<T>::get();
402404
let building_collective = BuildingCollective::<T>::get();
403405
let is_first_run = economic_collective.is_empty() || building_collective.is_empty();
404-
let should_rotate = now % T::CollectiveRotationPeriod::get() == Zero::zero();
405-
let should_cleanup = now % T::CleanupPeriod::get() == Zero::zero();
406+
let should_rotate = now
407+
.checked_rem(&T::CollectiveRotationPeriod::get())
408+
.unwrap_or(now)
409+
.is_zero();
410+
let should_cleanup = now
411+
.checked_rem(&T::CleanupPeriod::get())
412+
.unwrap_or(now)
413+
.is_zero();
406414

407415
if is_first_run || should_rotate {
408416
weight.saturating_accrue(Self::rotate_collectives());
@@ -419,6 +427,8 @@ pub mod pallet {
419427

420428
#[pallet::call]
421429
impl<T: Config> Pallet<T> {
430+
#![deny(clippy::expect_used)]
431+
422432
/// Set the allowed proposers.
423433
#[pallet::call_index(0)]
424434
#[pallet::weight(T::WeightInfo::set_allowed_proposers(T::MaxProposals::get()))]
@@ -565,7 +575,7 @@ pub mod pallet {
565575
ProposalOf::<T>::insert(proposal_hash, bounded_proposal);
566576

567577
let now = frame_system::Pallet::<T>::block_number();
568-
let end = now + T::MotionDuration::get();
578+
let end = now.saturating_add(T::MotionDuration::get());
569579
TriumvirateVoting::<T>::insert(
570580
proposal_hash,
571581
TriumvirateVotes {

0 commit comments

Comments
 (0)