Skip to content

Commit 8b14a60

Browse files
committed
Add linter rule to flag expect. Remove expects/allow exceptions.
1 parent cd2d306 commit 8b14a60

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+182
-63
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ edition = "2024"
4040

4141
[workspace.lints.clippy]
4242
arithmetic-side-effects = "deny"
43+
expect-used = "deny"
4344
indexing-slicing = "deny"
4445
manual_inspect = "allow"
4546
result_large_err = "allow"

node/src/chain_spec/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Allowed since it's actually better to panic during chain setup when there is an error
2-
#![allow(clippy::unwrap_used)]
2+
#![allow(clippy::expect_used, clippy::unwrap_used)]
33

44
pub mod devnet;
55
pub mod finney;

node/src/command.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ pub fn run() -> sc_cli::Result<()> {
245245
}
246246
}
247247

248+
#[allow(clippy::expect_used)]
248249
fn start_babe_service(arg_matches: &ArgMatches) -> Result<(), sc_cli::Error> {
249250
let cli = Cli::from_arg_matches(arg_matches).expect("Bad arg_matches");
250251
let runner = cli.create_runner(&cli.run)?;
@@ -281,6 +282,7 @@ fn start_babe_service(arg_matches: &ArgMatches) -> Result<(), sc_cli::Error> {
281282
}
282283
}
283284

285+
#[allow(clippy::expect_used)]
284286
fn start_aura_service(arg_matches: &ArgMatches) -> Result<(), sc_cli::Error> {
285287
let cli = Cli::from_arg_matches(arg_matches).expect("Bad arg_matches");
286288
let runner = cli.create_runner(&cli.run)?;
@@ -313,6 +315,7 @@ fn start_aura_service(arg_matches: &ArgMatches) -> Result<(), sc_cli::Error> {
313315
}
314316
}
315317

318+
#[allow(clippy::expect_used)]
316319
fn customise_config(arg_matches: &ArgMatches, config: Configuration) -> Configuration {
317320
let cli = Cli::from_arg_matches(arg_matches).expect("Bad arg_matches");
318321

node/src/consensus/babe_consensus.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ impl ConsensusMechanism for BabeConsensus {
4444
sp_timestamp::InherentDataProvider,
4545
);
4646

47+
#[allow(clippy::expect_used)]
4748
fn start_authoring<C, SC, I, PF, SO, L, CIDP, BS, Error>(
4849
self,
4950
task_manager: &mut TaskManager,

node/src/consensus/hybrid_import_queue.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ impl HybridBlockImport {
7777
FrontierBlockImport::new(grandpa_block_import.clone(), client.clone()),
7878
);
7979

80+
#[allow(clippy::expect_used)]
8081
let (babe_import, babe_link) = sc_consensus_babe::block_import(
8182
babe_config,
8283
grandpa_block_import.clone(),

node/src/service.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pub type BIQ<'a> = Box<
6060
+ 'a,
6161
>;
6262

63+
#[allow(clippy::expect_used)]
6364
pub fn new_partial(
6465
config: &Configuration,
6566
eth_config: &EthConfiguration,
@@ -250,6 +251,7 @@ pub fn build_manual_seal_import_queue(
250251
}
251252

252253
/// Builds a new service for a full client.
254+
#[allow(clippy::expect_used)]
253255
pub async fn new_full<NB, CM>(
254256
mut config: Configuration,
255257
eth_config: EthConfiguration,

pallets/admin-utils/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ mod tests;
1818

1919
#[deny(missing_docs)]
2020
#[frame_support::pallet]
21+
#[allow(clippy::expect_used)]
2122
pub mod pallet {
2223
use super::*;
2324
use frame_support::pallet_prelude::*;
@@ -162,6 +163,8 @@ pub mod pallet {
162163
/// Dispatchable functions allows users to interact with the pallet and invoke state changes.
163164
#[pallet::call]
164165
impl<T: Config> Pallet<T> {
166+
#![deny(clippy::expect_used)]
167+
165168
/// The extrinsic sets the new authorities for Aura consensus.
166169
/// It is only callable by the root account.
167170
/// The extrinsic will call the Aura pallet to change the authorities.

pallets/collective/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ pub struct Votes<AccountId, BlockNumber> {
179179

180180
#[deny(missing_docs)]
181181
#[frame_support::pallet]
182+
#[allow(clippy::expect_used)]
182183
pub mod pallet {
183184
use super::*;
184185
use frame_system::pallet_prelude::*;
@@ -397,6 +398,8 @@ pub mod pallet {
397398
// Note that councillor operations are assigned to the operational class.
398399
#[pallet::call]
399400
impl<T: Config<I>, I: 'static> Pallet<T, I> {
401+
#![deny(clippy::expect_used)]
402+
400403
/// Set the collective's membership.
401404
///
402405
/// - `new_members`: The new member list. Be nice to the chain and provide it sorted.

pallets/collective/src/tests.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
// See the License for the specific language governing permissions and
1616
// limitations under the License.
1717

18-
#![allow(non_camel_case_types, clippy::indexing_slicing, clippy::unwrap_used)]
18+
#![allow(
19+
non_camel_case_types,
20+
clippy::expect_used,
21+
clippy::indexing_slicing,
22+
clippy::unwrap_used
23+
)]
1924

2025
use super::{Event as CollectiveEvent, *};
2126
use crate as pallet_collective;

pallets/commitments/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type BalanceOf<T> =
3737
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
3838
#[deny(missing_docs)]
3939
#[frame_support::pallet]
40+
#[allow(clippy::expect_used)]
4041
pub mod pallet {
4142
use super::*;
4243
use frame_support::{pallet_prelude::*, traits::ReservableCurrency};
@@ -204,6 +205,8 @@ pub mod pallet {
204205

205206
#[pallet::call]
206207
impl<T: Config> Pallet<T> {
208+
#![deny(clippy::expect_used)]
209+
207210
/// Set the commitment for a given netuid
208211
#[pallet::call_index(0)]
209212
#[pallet::weight((

0 commit comments

Comments
 (0)