22
33extern crate alloc;
44
5+ use frame:: arithmetic:: CheckedRem ;
56use 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) ]
116118pub 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